mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 18:19:38 +02:00
Safari: important improvements to request capturing + fix twitch.tv
twitch.tv now works out of the box in HTML5 in Safari. Make sure you disable Flash if you don't get the HTML5 player.
This commit is contained in:
parent
dc36bf5321
commit
d2cc20ed47
@ -1,5 +1,5 @@
|
|||||||
7edb2a585b445f28aa5ab06306f1a23f assets/ublock/privacy.txt
|
7edb2a585b445f28aa5ab06306f1a23f assets/ublock/privacy.txt
|
||||||
2818b73e0bcbea13800c9c006b2d521d assets/ublock/filters.txt
|
f8ef909c16003b6ef79a502998c83dee assets/ublock/filters.txt
|
||||||
dcf3e05bae803343c9d632f0baf8bedd assets/ublock/mirror-candidates.txt
|
dcf3e05bae803343c9d632f0baf8bedd assets/ublock/mirror-candidates.txt
|
||||||
48f4e02826d244a48d140cb5e4b81114 assets/ublock/filter-lists.json
|
48f4e02826d244a48d140cb5e4b81114 assets/ublock/filter-lists.json
|
||||||
132b3ecc9da8a68c3faf740c00af734b assets/thirdparties/adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt
|
132b3ecc9da8a68c3faf740c00af734b assets/thirdparties/adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt
|
||||||
|
@ -292,3 +292,6 @@ deviantart.com##.dp-ad-chrome.dp-ad-visible
|
|||||||
# https://github.com/gorhill/uBlock/issues/774
|
# https://github.com/gorhill/uBlock/issues/774
|
||||||
# To counter `carbonads.net` in Peter Lowe's
|
# To counter `carbonads.net` in Peter Lowe's
|
||||||
@@||carbonads.net^$~third-party
|
@@||carbonads.net^$~third-party
|
||||||
|
|
||||||
|
# This enables twitch.tv to work in HTML5
|
||||||
|
@@||imasdk.googleapis.com$domain=twitch.tv
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
}
|
}
|
||||||
vAPI.vapiClientInjected = true;
|
vAPI.vapiClientInjected = true;
|
||||||
vAPI.safari = true;
|
vAPI.safari = true;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
var messagingConnector = function(response) {
|
var messagingConnector = function(response) {
|
||||||
if(!response) {
|
if(!response) {
|
||||||
@ -74,6 +75,9 @@
|
|||||||
requestId: 1,
|
requestId: 1,
|
||||||
connectorId: uniqueId(),
|
connectorId: uniqueId(),
|
||||||
setup: function() {
|
setup: function() {
|
||||||
|
if(typeof safari === "undefined") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.connector = function(msg) {
|
this.connector = function(msg) {
|
||||||
// messages from the background script are sent to every frame,
|
// messages from the background script are sent to every frame,
|
||||||
// so we need to check the connectorId to accept only
|
// so we need to check the connectorId to accept only
|
||||||
@ -107,6 +111,9 @@
|
|||||||
channelName: channelName,
|
channelName: channelName,
|
||||||
listener: typeof callback === 'function' ? callback : null,
|
listener: typeof callback === 'function' ? callback : null,
|
||||||
send: function(message, callback) {
|
send: function(message, callback) {
|
||||||
|
if(typeof safari === "undefined") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!vAPI.messaging.connector) {
|
if(!vAPI.messaging.connector) {
|
||||||
vAPI.messaging.setup();
|
vAPI.messaging.setup();
|
||||||
}
|
}
|
||||||
@ -157,8 +164,7 @@
|
|||||||
// Helper event to message background,
|
// Helper event to message background,
|
||||||
// and helper anchor element
|
// and helper anchor element
|
||||||
var beforeLoadEvent = new Event("beforeload"),
|
var beforeLoadEvent = new Event("beforeload"),
|
||||||
linkHelper = document.createElement("a"),
|
linkHelper = document.createElement("a");
|
||||||
isHttp_s = /^https?:/;
|
|
||||||
|
|
||||||
// Inform that we've navigated
|
// Inform that we've navigated
|
||||||
if(frameId === 0) {
|
if(frameId === 0) {
|
||||||
@ -186,10 +192,10 @@
|
|||||||
return !(safari.self.tab.canLoad(beforeLoadEvent, details));
|
return !(safari.self.tab.canLoad(beforeLoadEvent, details));
|
||||||
};
|
};
|
||||||
var onBeforeLoad = function(e) {
|
var onBeforeLoad = function(e) {
|
||||||
if(e.url.charCodeAt(0) !== 104 && !isHttp_s.test(e.url)) { // h = 104
|
linkHelper.href = e.url;
|
||||||
|
if(linkHelper.protocol.charCodeAt(0) !== 104) { // h = 104
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
linkHelper.href = e.url;
|
|
||||||
var details = {
|
var details = {
|
||||||
url: linkHelper.href,
|
url: linkHelper.href,
|
||||||
type: nodeTypes[e.target.nodeName.toLowerCase()] || "other",
|
type: nodeTypes[e.target.nodeName.toLowerCase()] || "other",
|
||||||
@ -199,7 +205,7 @@
|
|||||||
timeStamp: Date.now()
|
timeStamp: Date.now()
|
||||||
};
|
};
|
||||||
var response = safari.self.tab.canLoad(e, details);
|
var response = safari.self.tab.canLoad(e, details);
|
||||||
if(!response) {
|
if(response === false) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user