Skip to content

Commit

Permalink
Save CustomEvent in injected script (fixes #55)
Browse files Browse the repository at this point in the history
In case the website decides to overwrite it (e.g. http://www.javamagazine.mozaicreader.com/JanFeb2016)
  • Loading branch information
el1t committed Aug 29, 2017
1 parent 7149f1d commit eb2cc83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions platform/safari/client-injected.js
Expand Up @@ -20,17 +20,18 @@
*/

// __MSG_clientInjectedScript__
var ce = CustomEvent,
wo = open,
xo = XMLHttpRequest.prototype.open,
img = Image,
linkResolver = document.createElement('a');
var block = function(u, t) {
if (typeof u !== 'string') return false;
/* __MSG_eventScript__ */
document.documentElement.setAttribute('data-ublock-blocked', '');
document.dispatchEvent(e);
return !!document.documentElement.getAttribute('data-ublock-blocked');
};
var wo = open,
xo = XMLHttpRequest.prototype.open,
img = Image,
linkResolver = document.createElement('a');
Image = function() {
var x = new img(),
src = '';
Expand Down
2 changes: 1 addition & 1 deletion platform/safari/vapi-client.js
Expand Up @@ -601,7 +601,7 @@ var firstMutation = function() {
eventScript = 'var e = document.createEvent("CustomEvent");\
e.initCustomEvent("' + vAPI.sessionId + '", false, false, {url: u, type: t});'
} else {
eventScript = 'var e = new CustomEvent("' + vAPI.sessionId + '", {bubbles: false, detail: {url: u, type: t}});'
eventScript = 'var e = new ce("' + vAPI.sessionId + '", {bubbles: false, detail: {url: u, type: t}});'
}
tmpScript = tmpScript.replace('/* __MSG_eventScript__ */', eventScript);
if ( frameId === 0 ) {
Expand Down

0 comments on commit eb2cc83

Please sign in to comment.