Page 1 of 4 123 ... LastLast
Results 1 to 10 of 39
  1. #1
    Untangler
    Join Date
    Dec 2011
    Posts
    97

    Default convert Adblock plus txt file to json format

    I know this has been talked about before but does anyone have a script to convert the easylist.txt file for adblock plus into json format so that it can be used in UT adblock? I found this link:

    http://untangle.nu/upl/KJH84QN/easylist.json

    but it did not work.

  2. #2
    Untangle Ninja
    WebFooL's Avatar
    Join Date
    Jan 2009
    Location
    Sweden (Eskilstuna)
    Posts
    5,244

    Default

    Hi,

    Some of the lines has invalid signs so it will not import right.

    When i did the file a while back and i where going too do a filter that removed the lines that has a nonvalid sign but something else came instead.

  3. #3
    Untangler
    Join Date
    Dec 2011
    Posts
    97

    Default

    What are the invalid signs? I guess I can just do a sed or awk script to remove them?

  4. #4
    Untangle Ninja
    WebFooL's Avatar
    Join Date
    Jan 2009
    Location
    Sweden (Eskilstuna)
    Posts
    5,244

    Default

    Well some signes are used in the normal json format so you can not just run the hole file.

    I will see if i have the script that i generadet the file with then it is a easy task of adding a filter before it loops out the next line.

  5. #5
    Untangler
    Join Date
    Dec 2011
    Posts
    97

    Default

    Yes, I am sure many UT users will REALLY appreciate getting this working. Adblock Plus has the best ad blocking software I have ever seen.

  6. #6
    Untangle Ninja
    WebFooL's Avatar
    Join Date
    Jan 2009
    Location
    Sweden (Eskilstuna)
    Posts
    5,244

    Default

    put some time in to it but still there seams to be a problem.

    http:\\untangle.nu\gen\AD-Blocker.json

    If i run the line through http://jsonlint.com/
    I get:
    Parse error on line 2675:
    ... "javaClass": "com.untangle.uvm.n
    -----------------------^
    Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
    {
    "enabled": true,
    "string": "/ads.asp?",
    "javaClass": "com.untangle.uvm.n
    but the line in the file looks like this
    {"enabled":true,"string":"/ads.asp?","javaClass":"com.untangle.uvm.node.GenericRule"}
    And if i just run that on http://jsonlint.com/ it passes..

  7. #7
    Untangle Ninja sky-knight's Avatar
    Join Date
    Apr 2008
    Location
    Phoenix, AZ
    Posts
    26,162

    Default

    What about that space in GenericRule on the end?
    Rob Sandling, BS:SWE, MCP
    NexgenAppliances.com
    Phone: 866-794-8879 x201
    Email: support@nexgenappliances.com

  8. #8
    Untangle Ninja
    WebFooL's Avatar
    Join Date
    Jan 2009
    Location
    Sweden (Eskilstuna)
    Posts
    5,244

    Default

    It is a error in the quote display. there is nothing between r and i.

    And it is a darn loop

    Code:
    <?php
    $Content = "./easylist.txt"; 
    $lines = file($Content); 
    $vJsonFileName = "AD-Blocker". ".json"; 
    $badcharacters = array("#",'"', "'", "[", "]", "\n", "\t"); 
    header("Content-type: application/json"); 
    header("Content-Disposition: attachment; filename=$vJsonFileName");
    header('Cache-Control: public');
    echo "["; 
    foreach($lines as $str){ 
    $cleanstr = str_replace($badcharacters, "", $str);
    echo '{"enabled":true,"string":"'.$cleanstr.'","javaClass":"com.untangle.uvm.node.GenericRule"},'; 
    }
    echo "]"; 
    ?>
    So it should not start creating error on the 2675 line at least on that part.

  9. #9
    Untangler
    Join Date
    Dec 2011
    Posts
    97

    Default

    Lets put a bounty on it. It worked for Google.

  10. #10
    Untangle Ninja sky-knight's Avatar
    Join Date
    Apr 2008
    Location
    Phoenix, AZ
    Posts
    26,162

    Default

    Well your array of bad elements is missing a space between the first and second element that is making my OCD go nuts. I don't think that will throw PHP however...

    Code:
    header("Content-Disposition: attachment; filename=$vJsonFileName");
    Isn't that semicolon after attachment a problem?

    But if the error is in the loop, yeah I don't see an issue there.
    Rob Sandling, BS:SWE, MCP
    NexgenAppliances.com
    Phone: 866-794-8879 x201
    Email: support@nexgenappliances.com

Page 1 of 4 123 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO 3.6.0 PL2