From 791a025ad5ce7de6b1bf259b5eb631fd4e76727f Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 26 Nov 2015 11:13:33 -0500 Subject: [PATCH] redirect engine: code review + added more neutered resources --- assets/checksums.txt | 2 +- assets/ublock/redirect-resources.txt | 104 +++++++++++++++++++-------- src/js/redirect-engine.js | 4 +- 3 files changed, 78 insertions(+), 32 deletions(-) diff --git a/assets/checksums.txt b/assets/checksums.txt index 91de4f4e2..c78bb7783 100644 --- a/assets/checksums.txt +++ b/assets/checksums.txt @@ -1,5 +1,5 @@ a65d3b35ba116f897c7ef5db2046da73 assets/ublock/unbreak.txt -7d7d8d4d795ad6821e2a728790b8d0f1 assets/ublock/redirect-resources.txt +487882164fd6aa571fbc10d5f01eb7e1 assets/ublock/redirect-resources.txt 7a04294b44b88baa34cf3e4bfe0e59db assets/ublock/privacy.txt b2dbf435507aa0262b289c67cbef2142 assets/ublock/filters.txt 146704ad1c0393e342afdb416762c183 assets/ublock/badware.txt diff --git a/assets/ublock/redirect-resources.txt b/assets/ublock/redirect-resources.txt index be9b36800..e69e44505 100644 --- a/assets/ublock/redirect-resources.txt +++ b/assets/ublock/redirect-resources.txt @@ -12,7 +12,9 @@ hd-main.js application/javascript var L = (function(){ var l = {}; - var noopfn = function() {}; + var noopfn = function() { + ; + }; var props = ["pf", "ed", "Qe", "fd", "xh", "Uc", "ef", "zd", "Ad", "Qc", "Ri", "Wc", "Vc", "Xc", "Wg", "rd", "qd", "sd", "Pe", "Id", "Hd", "Jd", "fg", "Fd", "Ed", "Gd", "ek", "Cd", "Bd", "Dd", "Nj", "Sc", "Rc", "Tc", "wg", "xd", "wd", "yd", "fh", "ld", "md", "nd", "Re", "cd", "Pc", "ke", "Yc", "Xg", "jd", "kd", "oh", "ad", "bd", "mi", "gd", "hd", "ae", "dd", "fk", "ij", "ud", "td", "vd", "ig", "od", "pd", "Yd", "$j", "Oc", "bf"]; for (var i = 0; i < props.length; i++) { l[props[i]] = noopfn; @@ -26,37 +28,81 @@ handtinytrans.gif image/gif;base64 R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== +fuckadblock.js-3.2.0 application/javascript +(function() { + var noopfn = function() { + ; + }; + // + var Fab = function() {}; + Fab.prototype._bait = null; + Fab.prototype._checkBait = noopfn; + Fab.prototype._creatBait = noopfn; + Fab.prototype._destroyBait = noopfn; + Fab.prototype._log = noopfn; + Fab.prototype._options = null; + Fab.prototype._stopLoop = noopfn; + Fab.prototype._var = null; + Fab.prototype.check = noopfn; + Fab.prototype.clearEvent = noopfn; + Fab.prototype.emitEvent = noopfn; + Fab.prototype.on = function(a, b) { + if ( !a ) { b(); } + }; + Fab.prototype.onDetected = noopfn; + Fab.prototype.onNotDetected = function(a) { + a(); + }; + Fab.prototype.setOption = noopfn; + window.FuckAdBlock = Fab; + // + window.fuckAdBlock = new Fab(); +})(); + + +noopframe text/html + + + + + + + # To neutralize GA scripts. The goal is to provide the minimal API # expected by clients of these scripts so that the end users are able # to wholly block GA while minimizing risks of page breakage. # Test cases (need way more): # - https://github.com/chrisaljoudi/uBlock/issues/119 -#www.google-analytics.com/ga.js application/javascript -#(function() { -# var noopfn = function() {}; -# // -# var gaq = function() {}; -# gaq.push = function(a) { -# if ( typeof a === 'function' ) { -# a(); -# } -# }; -# // -# var tracker = function() {}; -# tracker._getLinkerUrl = function(a) { return a; }; -# // -# var gat = function() {}; -# gat._getTrackerByName = function() { return tracker; }; -# window._gat = gat; -# // -# (function() { -# var aa = window._gaq || []; -# if ( Array.isArray(aa) ) { -# while ( aa[0] ) { -# gaq.push(aa.shift()); -# } -# } -# })(); -# window._gaq = gaq; -#})(); +www.google-analytics.com/ga.js application/javascript +(function() { + var noopfn = function() { + ; + }; + // + var gaq = function() { + ; + }; + gaq.push = function(a) { + if ( typeof a === 'function' ) { + a(); + } + }; + // + var tracker = function() {}; + tracker._getLinkerUrl = function(a) { return a; }; + // + var gat = function() {}; + gat._getTrackerByName = function() { return tracker; }; + window._gat = gat; + // + (function() { + var aa = window._gaq || []; + if ( Array.isArray(aa) ) { + while ( aa[0] ) { + gaq.push(aa.shift()); + } + } + })(); + window._gaq = gaq; +})(); diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js index 3c271bd70..779d1a94a 100644 --- a/src/js/redirect-engine.js +++ b/src/js/redirect-engine.js @@ -156,7 +156,7 @@ RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) { if ( type !== undefined ) { return; } - type = option; + type = this.supportedTypes[option]; continue; } } @@ -201,7 +201,7 @@ RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) { /******************************************************************************/ -RedirectEngine.prototype.reFilterParser = /^\|\|([^\/\?#]+)([^$]+)\$([^$]+)$/; +RedirectEngine.prototype.reFilterParser = /^\|\|([^\/?#^*]+)([^$]+)\$([^$]+)$/; RedirectEngine.prototype.supportedTypes = (function() { var types = Object.create(null);