Announcement

Collapse
No announcement yet.

Anyway to import easy list into untangle?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anyway to import easy list into untangle?

    Yes the AD Blocker for some reason doesn't work as well as my pihole and Im trying to work with it. I literally get zero blocked ads as I stare at a Comcast ad on CNN..... I would like to not run adblocker extension which does get rid of that very ad.

    Is there anyway to get the best out of this AD Blocker by importing easy list into it? I have tried a script someone posted here but that seems to not work now. Also tried some online txt file to json convertor no dice there either. It seems easy list is pretty big.

    Any help would be appreciated as normal.

  • #3
    Yeah that's the one I tried but it didn't work. Powershell no matter what was throwing errors. Also I don't see where it output the file

    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:167 char:21
    + Sign up
    + ~
    The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:194 char:190
    + ... ata-ga-click="(Logged out) Header, go to Features">Features <span cla ...
    + ~
    The '<' operator is reserved for future use.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:194 char:266
    + ... p-link-symbol float-right text-normal text-gray-light pr-3">&rarr;</s ...
    + ~
    The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:196 char:159
    + ... d-block link-gray no-underline f5 Bump-link--hover">Mobile <span cla ...
    + ~
    The '<' operator is reserved for future use.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:196 char:235
    + ... p-link-symbol float-right text-normal text-gray-light pr-3">&rarr;</s ...
    + ~
    The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:197 char:170
    + ... d-block link-gray no-underline f5 Bump-link--hover">Actions <span cla ...
    + ~
    The '<' operator is reserved for future use.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:197 char:246
    + ... p-link-symbol float-right text-normal text-gray-light pr-3">&rarr;</s ...
    + ~
    The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:198 char:176
    + ... lock link-gray no-underline f5 Bump-link--hover">Codespaces <span cla ...
    + ~
    The '<' operator is reserved for future use.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:198 char:252
    + ... p-link-symbol float-right text-normal text-gray-light pr-3">&rarr;</s ...
    + ~
    The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    At C:\Users\CaraJean\Downloads\UTJSEasyList.ps1:199 char:172
    + ... -block link-gray no-underline f5 Bump-link--hover">Packages <span cla ...
    + ~
    The '<' operator is reserved for future use.
    Not all parse errors were reported. Correct the reported errors and try again.
    + CategoryInfo : ParserError: ( [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed

    Comment


    • #4
      I'll take a look and see whats wrong.
      "Of all the things I've lost, I miss my mind the most"
      [email protected]
      http://gustavsson.it

      Comment


      • #5
        Originally posted by WebFooL View Post
        I'll take a look and see whats wrong.
        Thank You! I appreciate you for doing this.

        Comment


        • #6
          Looks to run fine at my end.
          The scripts complains on line 167 at your end but there is only 42 lines in the script..
          Do you have a print screen of your powershell windows?

          And try running it in Powershell_ISE
          "Of all the things I've lost, I miss my mind the most"
          [email protected]
          http://gustavsson.it

          Comment


          • #8
            Originally posted by WebFooL View Post
            Try importing this file:
            I think that will work except the page keeps going unresponsive when I go to save the import... Is this normal? I clicked replace what was there.

            Comment


            • #9
              They might have added a limit on the import size.
              I can modify so it creates multiple smaller files.
              "Of all the things I've lost, I miss my mind the most"
              [email protected]
              http://gustavsson.it

              Comment


              • #10
                Try this (see code below) it should create import files with 5000 lines en each file.
                Importing the first file and relpace current settings.
                Next number of files append.

                Hit save between every time.


                Code:
                ##
                ## Script Create by WebFooL for The Untangle Community
                ##
                $easylistsource = "https://easylist.to/easylist/easylist.txt"
                $Request = Invoke-WebRequest $easylistsource
                $EasyList = $Request.Content
                $filenamejson = "ADImport.json"
                $filenamecsv = "ADImport.csv"
                $easylistsourcecount=($EasyList | Measure-Object –Line).Lines
                $hash = $null
                $counter = 0
                $hash = @'
                string,blocked,javaClass,markedForNew,markedForDelete,enabled
                
                
                '@
                
                
                write-host "Will now work for a while do not panic!"
                ForEach ($line in $($EasyList -split "`n"))
                {
                #Add Nice Progress bar.. 
                Write-Progress -Activity "Processing Easylist" -CurrentOperation $line -PercentComplete (($counter / $easylistsourcecount) * 100)
                    #Remove all Commented lines (They all start with !)
                    if($line -clike '!*') {
                    #Do Nothing
                    } elseif($line -eq "[Adblock Plus 2.0]"){
                    #Do Nothing
                    }elseif($line -eq ""){
                    #Do Nothing
                    }else {
                        #Create Untangle JSON
                        $hash += "$line,true,com.untangle.uvm.app.GenericRule,true,false,true`r`n"
                        $counter++
                    }    
                }
                #Tempstore as CSV
                $hash | Set-Content -Path $filenamecsv
                
                
                function Split-CsvFile {
                    param (
                        [string]$sourceCSV,
                        [int]$size
                    )
                
                
                    $exportPath = $sourceCSV.Substring(0, $sourceCSV.LastIndexOf('.'))
                    $count = (Import-Csv $sourceCSV).count
                    $startrow = 0;
                    $counter  = 1;
                
                
                    while ($startrow -lt $count) {
                        $filename = "$($exportPath)_$($counter)"
                        Write-host "Filename:" $filename
                        Import-CSV $sourceCSV | select-object -skip $startrow -first $size | Export-CSV "$filename.csv" -NoClobber -Encoding UTF8 -NoTypeInformation
                        #Convert to Json
                        import-csv "$filename.csv" | ConvertTo-Json -Compress | Set-Content -Path "$filename.json"
                        if (Test-Path "$filename.csv") {
                          Remove-Item "$filename.csv"
                        }
                        $startrow += $size
                        $counter++
                    }
                }
                
                
                Split-CsvFile -sourceCSV $filenamecsv -size 5000 
                #import-csv $filenamecsv | ConvertTo-Json -Compress | Set-Content -Path $filenamejson
                #Count lines in the CSV
                $numberoflines = (Import-Csv $filenamecsv | Measure-Object -Property string).Count
                #Write friendly exit message
                Write-Host "Done you now have a few $filenamejson with $numberoflines lines from $easylistsource"
                "Of all the things I've lost, I miss my mind the most"
                [email protected]
                http://gustavsson.it

                Comment


                • #11
                  Thanks for making this script, WebFool, but I get the following error when running it.

                  Code:
                  → ~\OneDrive\Desktop› .\easylist2untangle.ps1
                  At C:\Users\mrhan\OneDrive\Desktop\easylist2untangle.ps1:74 char:97
                  + ... e a few $filenamejson with $numberoflines lines from $easylistsource"
                  +                                                                         ~
                  The string is missing the terminator: ".
                  At C:\Users\mrhan\OneDrive\Desktop\easylist2untangle.ps1:74 char:98
                  + ... e a few $filenamejson with $numberoflines lines from $easylistsource"
                  +                                                                          ~
                  Missing closing ')' in expression.
                      + CategoryInfo          : ParserError: (:) [], ParseException
                      + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
                  I'm not familiar with PS scripts. I tried adding a # and ) at the end, but then it gives a different error.

                  Code:
                  Measure-Object : A positional parameter cannot be found that accepts argument 'now'.
                  At C:\Users\mrhan\OneDrive\Desktop\easylist2untangle.ps1:9 char:35
                  + $easylistsourcecount=($EasyList | Measure-Object –Line).Lines
                  +                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                      + CategoryInfo          : InvalidArgument: (:) [Measure-Object], ParameterBindingException
                      + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand
                  Weirdly, it works if I run it line by line. At least, it generates the files, but I still can't import them. It hangs for a few minutes after clicking save, then all the user added filters are blank.
                  Last edited by [email protected]; 02-03-2021, 09:38 PM.

                  Comment


                  • #12
                    Looks like you have some Copy-Paste error and missing a ".

                    I'll see if i have the time to commit my changes to git tomorrow and you can download the script from there.
                    "Of all the things I've lost, I miss my mind the most"
                    [email protected]
                    http://gustavsson.it

                    Comment


                    • #13
                      Same here. Tried importing but on hitting save it just hangs.....

                      Comment


                      • #14
                        What if you modify the 5000 to a lower number?
                        "Of all the things I've lost, I miss my mind the most"
                        [email protected]
                        http://gustavsson.it

                        Comment


                        • #15
                          I have changed 5000 in the script to 2000 and am running it now.
                          Let's see.

                          Comment

                          Working...
                          X
                          😀
                          🥰
                          🤢
                          😎
                          😡
                          👍
                          👎