mirror of https://github.com/gorhill/uBlock.git
Safari: make it work on version 5
This commit is contained in:
parent
0306f52c0e
commit
252eb1b4dc
|
@ -160,9 +160,18 @@
|
|||
|
||||
// Helper event to message background,
|
||||
// and helper anchor element
|
||||
var beforeLoadEvent = new Event("beforeload"),
|
||||
var beforeLoadEvent,
|
||||
legacyMode = false,
|
||||
linkHelper = document.createElement("a");
|
||||
|
||||
try {
|
||||
beforeLoadEvent = new Event("beforeload")
|
||||
} catch (ex) {
|
||||
legacyMode = true;
|
||||
beforeLoadEvent = document.createEvent("Event");
|
||||
beforeLoadEvent.initEvent("beforeload");
|
||||
}
|
||||
|
||||
// Inform that we've navigated
|
||||
if(frameId === 0) {
|
||||
safari.self.tab.canLoad(beforeLoadEvent, {
|
||||
|
@ -223,15 +232,14 @@
|
|||
var tmpJS = document.createElement("script");
|
||||
var tmpScript = "\
|
||||
(function() {\
|
||||
var block = function(u, t) {\
|
||||
var e = new CustomEvent('" + vAPI.sessionId + "', {\
|
||||
detail: {\
|
||||
url: u,\
|
||||
type: t\
|
||||
},\
|
||||
bubbles: false\
|
||||
});\
|
||||
document.dispatchEvent(e);\
|
||||
var block = function(u, t) {" +
|
||||
( legacyMode
|
||||
? "var e = document.createEvent('CustomEvent');\
|
||||
e.initCustomEvent('" + vAPI.sessionId + "', false, false, {url: u, type: t});"
|
||||
: "var e = new CustomEvent('" + vAPI.sessionId + "',\
|
||||
{bubbles: false, detail: {url: u, type: t}});"
|
||||
) +
|
||||
"document.dispatchEvent(e);\
|
||||
return e.detail.url === false;\
|
||||
},\
|
||||
wo = open,\
|
||||
|
|
Loading…
Reference in New Issue