Disrupt loading of ads from malicious/irresponsible providers.
This commit is contained in:
parent
94502f64cb
commit
6b359c9b8c
@ -20,13 +20,16 @@
|
||||
"matches": [
|
||||
"*://boards.4chan.org/*",
|
||||
"*://sys.4chan.org/*",
|
||||
"*://www.4chan.org/*",
|
||||
"*://i.4cdn.org/*",
|
||||
"*://www.4chan.org/banned",
|
||||
"*://www.4chan.org/feedback",
|
||||
"https://www.google.com/recaptcha/api2/anchor?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*",
|
||||
"https://www.google.com/recaptcha/api2/frame?*&k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*",
|
||||
"*://www.google.com/recaptcha/api/fallback?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*"
|
||||
],
|
||||
"exclude_matches": [
|
||||
"*://www.4chan.org/pass",
|
||||
"*://www.4chan.org/pass?*"
|
||||
],
|
||||
"grants": [
|
||||
"GM_getValue",
|
||||
"GM_setValue",
|
||||
|
||||
@ -314,7 +314,11 @@ $.globalEval = (code) ->
|
||||
$.rm script
|
||||
|
||||
$.global = (fn) ->
|
||||
$.globalEval "(#{fn})();"
|
||||
if doc
|
||||
$.globalEval "(#{fn})();"
|
||||
else
|
||||
# XXX dwb
|
||||
fn()
|
||||
|
||||
$.bytesToString = (size) ->
|
||||
unit = 0 # Bytes
|
||||
|
||||
@ -13,6 +13,18 @@ Main =
|
||||
$.ready -> Captcha.fixes.init()
|
||||
return
|
||||
|
||||
# Disrupt loading of ads from malicious/irresponsible providers.
|
||||
$.global ->
|
||||
nuke = (obj, prop) ->
|
||||
try
|
||||
Object.defineProperty obj, prop,
|
||||
configurable: false
|
||||
get: -> throw new Error()
|
||||
set: -> throw new Error()
|
||||
for prop in ['atOptions', 'adsterra_key', 'EpmadsConfig', 'epmads_key', 'EpomConfig', 'epom_key', 'exoDocumentProtocol']
|
||||
nuke window, prop
|
||||
return
|
||||
|
||||
# Detect multiple copies of 4chan X
|
||||
$.on d, '4chanXInitFinished', ->
|
||||
if Main.expectInitFinished
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
"content_scripts": [{
|
||||
"js": ["script.js"],
|
||||
"matches": <%= JSON.stringify(meta.matches) %>,
|
||||
"exclude_matches": <%= JSON.stringify(meta.exclude_matches) %>,
|
||||
"all_frames": true,
|
||||
"run_at": "document_start"
|
||||
}],
|
||||
|
||||
@ -7,16 +7,32 @@
|
||||
// @description <%= description %>
|
||||
// @license MIT; <%= meta.license %>
|
||||
<%=
|
||||
meta.matches.map(function(match) {
|
||||
if (/^\*/.test(match)) {
|
||||
return (
|
||||
'// @include ' + match.replace(/^\*/, 'http') + '\n' +
|
||||
'// @include ' + match.replace(/^\*/, 'https')
|
||||
);
|
||||
} else {
|
||||
return '// @include ' + match;
|
||||
(function() {
|
||||
function expand(items, regex, substitutions) {
|
||||
var results = [];
|
||||
items.forEach(function(item) {
|
||||
if (regex.test(item)) {
|
||||
substitutions.forEach(function(s) {
|
||||
results.push(item.replace(regex, s));
|
||||
});
|
||||
} else {
|
||||
results.push(item);
|
||||
}
|
||||
});
|
||||
return results;
|
||||
}
|
||||
}).join('\n')
|
||||
function expandMatches(matches) {
|
||||
return expand(matches, /^\*/, ['http', 'https']);
|
||||
}
|
||||
return [].concat(
|
||||
expandMatches(meta.matches).map(function(match) {
|
||||
return '// @include ' + match;
|
||||
}),
|
||||
expandMatches(meta.exclude_matches).map(function(match) {
|
||||
return '// @exclude ' + match;
|
||||
})
|
||||
).join('\n');
|
||||
})()
|
||||
%>
|
||||
<%=
|
||||
meta.grants.map(function(grant) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user