Skip to content

Commit

Permalink
Update FOP to version 3.19
Browse files Browse the repository at this point in the history
* Added more known options and sorted it (thanks for @realodix, https://github.com/realodix/AdBlockID/blob/master/tools/fop/common.py)
* Fixed problems with sorting some AdGuard's rules (#4)
  • Loading branch information
hawkeye116477 committed Jun 7, 2020
1 parent 697f031 commit 60156c8
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions scripts/FOP.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>."""
# FOP version number
VERSION = 3.18
VERSION = 3.19

# Import the key modules
import collections, filecmp, os, re, subprocess, sys
Expand All @@ -39,7 +39,7 @@
# Compile regular expressions to match important filter parts (derived from Wladimir Palant's Adblock Plus source code)
ELEMENTDOMAINPATTERN = re.compile(r"^([^\/\*\|\@\"\!]*?)(#|\$)\@?\??\@?(#|\$)")
FILTERDOMAINPATTERN = re.compile(r"(?:\$|\,)domain\=([^\,\s]+)$")
ELEMENTPATTERN = re.compile(r"^([^\/\*\|\@\"\!]*?)(\$|##\@?\$|#\@?#?\+?)([^{]+)$")
ELEMENTPATTERN = re.compile(r"^([^\/\*\|\@\"\!]*?)(\$|##\@?\$|#\@?#?\+?)(.*)$")
OPTIONPATTERN = re.compile(r"^(.*)\$(~?[\w\-]+(?:=[^,\s]+)?(?:,~?[\w\-]+(?:=[^,\s]+)?)*)$")

# Compile regular expressions that match element tags and pseudo classes and strings and tree selectors; "@" indicates either the beginning or the end of a selector
Expand All @@ -60,25 +60,35 @@
IGNORE = ("output", "requirements.txt", "templates", "node_modules")

# List all Adblock Plus, uBlock Origin and AdGuard options (excepting domain, which is handled separately), as of version 1.3.9
KNOWNOPTIONS = ("badfilter", "collapse", "csp", "css", "document", "elemhide",
"font", "genericblock", "generichide", "image", "match-case",
"object", "media", "object-subrequest", "other", "ping", "popup",
"script", "stylesheet", "subdocument", "third-party", "first-party",
"websocket", "webrtc", "xmlhttprequest", "important", "redirect=googletagmanager_gtm.js",
"redirect=google-analytics_ga.js", "redirect=google-analytics_analytics.js", "redirect=googletagservices_gpt.js",
"redirect=google-analytics_cx_api.js", "redirect=googlesyndication_adsbygoogle.js", "redirect=doubleclick_instream_ad_status.js",
"redirect=ampproject_v0.js", "redirect=noop.js", "redirect=noop.html", "redirect=noop.txt",
"redirect=noop-0.1s.mp3", "redirect=noop-1s.mp4", "redirect=1x1.gif", "redirect=2x2.png",
"redirect=3x2.png", "redirect=32x32.png", "redirect=noeval-silent.js",
"rewrite=abp-resource:blank-css", "rewrite=abp-resource:blank-js", "rewrite=abp-resource:blank-html", "rewrite=abp-resource:blank-mp3", "rewrite=abp-resource:blank-text", "rewrite=abp-resource:1x1-transparent-gif", "rewrite=abp-resource:2x2-transparent-png", "rewrite=abp-resource:3x2-transparent-png", "rewrite=abp-resource:32x32-transparent-png",
"1p", "3p", "inline-script", "xhr", "protobuf", "urlblock", "jsinject",
"redirect-rule=googletagmanager_gtm.js",
"redirect-rule=google-analytics_ga.js", "redirect-rule=google-analytics_analytics.js", "redirect-rule=googletagservices_gpt.js",
"redirect-rule=google-analytics_cx_api.js", "redirect-rule=googlesyndication_adsbygoogle.js", "redirect-rule=doubleclick_instream_ad_status.js",
"redirect-rule=ampproject_v0.js", "redirect-rule=noop.js", "redirect-rule=noop.html", "redirect-rule=noop.txt",
"redirect-rule=noop-0.1s.mp3", "redirect-rule=noop-1s.mp4", "redirect-rule=1x1.gif", "redirect-rule=2x2.png",
"redirect-rule=3x2.png", "redirect-rule=32x32.png",
"empty", "mp4", "extension", "stealth", "content", "redirect=noeval.js")
KNOWNOPTIONS = (
"document", "elemhide", "font", "genericblock", "generichide", "image", "match-case", "media", "object", "other", "ping", "popup", "script", "stylesheet", "subdocument", "third-party", "webrtc", "websocket", "xmlhttprequest",
"rewrite=abp-resource:blank-css", "rewrite=abp-resource:blank-js", "rewrite=abp-resource:blank-html", "rewrite=abp-resource:blank-mp3", "rewrite=abp-resource:blank-text", "rewrite=abp-resource:1x1-transparent-gif", "rewrite=abp-resource:2x2-transparent-png", "rewrite=abp-resource:3x2-transparent-png", "rewrite=abp-resource:32x32-transparent-png",

# uBlock Origin
"1p", "first-party", "3p", "all", "badfilter", "cname", "csp", "css", "denyallow", "doc", "ehide", "empty", "frame", "ghide", "important", "inline-font", "inline-script", "mp4", "object-subrequest", "popunder", "shide", "specifichide", "xhr",
"redirect=1x1.gif", "redirect-rule=1x1.gif",
"redirect=2x2.png","redirect-rule=2x2.png",
"redirect=3x2.png","redirect-rule=3x2.png",
"redirect=32x32.png", "redirect-rule=32x32.png",
"redirect=noop-0.1s.mp3", "redirect-rule=noop-0.1s.mp3",
"redirect=noop-1s.mp4","redirect-rule=noop-1s.mp4",
"redirect=noop.html", "redirect-rule=noop.html",
"redirect=noop.js", "redirect-rule=noop.js",
"redirect=noop.txt", "redirect-rule=noop.txt",
"redirect=noopcss", "redirect-rule=noopcss",
"redirect=ampproject_v0.js", "redirect-rule=ampproject_v0.js",
"redirect=nofab.js" "redirect-rule=nofab.js"
"redirect=fuckadblock.js-3.2.0" "redirect-rule=fuckadblock.js-3.2.0"
"redirect=google-analytics_cx_api.js", "redirect-rule=google-analytics_cx_api.js",
"redirect=google-analytics_analytics.js", "redirect-rule=google-analytics_analytics.js",
"redirect=google-analytics_ga.js", "redirect-rule=google-analytics_ga.js",
"redirect=googlesyndication_adsbygoogle.js", "redirect-rule=googlesyndication_adsbygoogle.js",
"redirect=googletagmanager_gtm.js", "redirect-rule=googletagmanager_gtm.js",
"redirect=googletagservices_gpt.js", "redirect-rule=googletagservices_gpt.js",

# AdGuard
"app", "content", "cookie", "extension", "jsinject", "network", "replace", "stealth", "urlblock"
)

# List the supported revision control system commands
REPODEF = collections.namedtuple("repodef", "name, directory, locationoption, repodirectoryoption, checkchanges, difference, commit, pull, push")
Expand Down

0 comments on commit 60156c8

Please sign in to comment.