Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/gwarser/noads-advanced

  • Loading branch information...
commit 59105b302ed86ecb5e14932c215083be76822e34 2 parents bc1ce52 + c381b01
@Gemorroj authored
View
2  includes/noads-common.js
@@ -73,7 +73,7 @@ splitCSS = function (css) {
},
getTLD = function (domain, full) {
if (!domain) return '';
- var r = domain.match(/^((?:\d{1,3}\.){3})\d{1,3}$/);
+ var r = /^((?:\d{1,3}\.){3})\d{1,3}$/.exec(domain);
if (r) return r[1] + '0';
var a = domain.split('.'), l = a.length;
if (l < 2) return domain;
View
12 includes/noads-service.js
@@ -69,7 +69,7 @@ var noads = {
n = a.nodeName.toLowerCase();
if (r.test(n)) {
if (n === 'id') {
- if (a.nodeValue.match(/[^_a-zA-Z0-9-]/i)) {
+ if (/[^_a-zA-Z0-9-]/i.test(a.nodeValue)) {
// check for unallowed values
continue;
}
@@ -78,7 +78,7 @@ var noads = {
} else if (n === 'class') {
if (~a.nodeValue.indexOf(' ')) {
rez += '[' + n + '=\x22' + a.nodeValue.replace(/[\x22\x5C]/g, '\\$&') + '\x22]';
- } else if (!a.nodeValue.match(/[^_a-zA-Z0-9-]/i)) {
+ } else if (!/[^_a-zA-Z0-9-]/i.test(a.nodeValue)) {
// check for unallowed values
rez += '.' + a.nodeValue.replace(/[\x22\x5C]/g, '');
}
@@ -136,11 +136,11 @@ var noads = {
getFilterLink: function (css, domain) {
if (/not\s*\(/i.test(css)) return;
- var ruleURL = css.match(/(?:src|href|data)\s*\^=\s*"([^"]+)"/i);
+ var ruleURL = /(?:src|href|data)\s*\^=\s*"([^"]+)"/i.exec(css);
if (ruleURL && ruleURL[1]) {
ruleURL[1] += '*';
} else {
- ruleURL = css.match(/(?:src|href|data)\s*\*=\s*"([^"]+)"/i);
+ ruleURL = /(?:src|href|data)\s*\*=\s*"([^"]+)"/i.exec(css);
if (ruleURL && ruleURL[1]) {
if (ruleURL[1].length < 5) {
return;
@@ -148,13 +148,13 @@ var noads = {
ruleURL[1] = '*' + ruleURL[1] + '*';
}
} else {
- ruleURL = css.match(/(?:src|href|data)\s*=\s*"([^"]+)"/i);
+ ruleURL = /(?:src|href|data)\s*=\s*"([^"]+)"/i.exec(css);
if (!ruleURL || !ruleURL[1]) return;
}
}
ruleURL[1] = ruleURL[1].replace(/^\.\/|\.\.\/?/g,'*'); // "../" or "./" -> *
- if (ruleURL[1].match(/^https?:?\/?\/?\*+$/gi)) return; // "http(s)://"
+ if (/^https?:?\/?\/?\*+$/i.test(ruleURL[1])) return; // "http(s)://"
if (ruleURL[1].indexOf('http') === -1) {
if (domain) {
if (ruleURL[1].indexOf('*') !== 0 && (ruleURL[1].charAt(0) === '/' || domain.charAt(domain.length - 1) === '/')) {
View
6 includes/noads.js
@@ -133,7 +133,7 @@ function onBeforeExternalScriptHandler(e) {
var src = e.element.src;
if (!src || reSkip.test(src)) return;
var full = !/\.(com|net|org|edu|gov|mil|int|[a-z]{2})$/i.test(domain);
- if (getTLD(src.match(/^https?:\/\/(?:[^\/]+@)?([^:\/]+)/i)[1], full) !== getTLD(domain, full)) {
+ if (getTLD(/^https?:\/\/(?:[^\/]+@)?([^:\/]+)/i.exec(src)[1], full) !== getTLD(domain, full)) {
e.preventDefault();
if (blockedScripts.indexOf(src) === -1) {
blockedScripts += blockedScripts ? '; ' + src : src;
@@ -191,7 +191,7 @@ function setupMagic() {
j = jS.split(' ');
ret = window.parseInt(j[2], 10);
ret = window.isNaN(ret) ? null : ret;
- if (j[0].match(/^function/i)) {
+ if (/^function/i.test(j[0])) {
// blocking functions
blockedFuncs += ',' + j[1];
@@ -209,7 +209,7 @@ function setupMagic() {
return null;
};
})(j[1], debug);
- } else if (j[0].match(/^var/i)) {
+ } else if (/^var/i.test(j[0])) {
//blocking variables
blockedVars += ',' + j[1];
window[j[1]] = ret;
Please sign in to comment.
Something went wrong with that request. Please try again.