1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +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:
Chris 2015-02-12 16:29:58 -07:00
parent dc36bf5321
commit d2cc20ed47
3 changed files with 15 additions and 6 deletions

View File

@ -1,5 +1,5 @@
7edb2a585b445f28aa5ab06306f1a23f assets/ublock/privacy.txt
2818b73e0bcbea13800c9c006b2d521d assets/ublock/filters.txt
f8ef909c16003b6ef79a502998c83dee assets/ublock/filters.txt
dcf3e05bae803343c9d632f0baf8bedd assets/ublock/mirror-candidates.txt
48f4e02826d244a48d140cb5e4b81114 assets/ublock/filter-lists.json
132b3ecc9da8a68c3faf740c00af734b assets/thirdparties/adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt

View File

@ -292,3 +292,6 @@ deviantart.com##.dp-ad-chrome.dp-ad-visible
# https://github.com/gorhill/uBlock/issues/774
# To counter `carbonads.net` in Peter Lowe's
@@||carbonads.net^$~third-party
# This enables twitch.tv to work in HTML5
@@||imasdk.googleapis.com$domain=twitch.tv

View File

@ -29,6 +29,7 @@
}
vAPI.vapiClientInjected = true;
vAPI.safari = true;
/******************************************************************************/
var messagingConnector = function(response) {
if(!response) {
@ -74,6 +75,9 @@
requestId: 1,
connectorId: uniqueId(),
setup: function() {
if(typeof safari === "undefined") {
return;
}
this.connector = function(msg) {
// messages from the background script are sent to every frame,
// so we need to check the connectorId to accept only
@ -107,6 +111,9 @@
channelName: channelName,
listener: typeof callback === 'function' ? callback : null,
send: function(message, callback) {
if(typeof safari === "undefined") {
return;
}
if(!vAPI.messaging.connector) {
vAPI.messaging.setup();
}
@ -157,8 +164,7 @@
// Helper event to message background,
// and helper anchor element
var beforeLoadEvent = new Event("beforeload"),
linkHelper = document.createElement("a"),
isHttp_s = /^https?:/;
linkHelper = document.createElement("a");
// Inform that we've navigated
if(frameId === 0) {
@ -186,10 +192,10 @@
return !(safari.self.tab.canLoad(beforeLoadEvent, details));
};
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;
}
linkHelper.href = e.url;
var details = {
url: linkHelper.href,
type: nodeTypes[e.target.nodeName.toLowerCase()] || "other",
@ -199,7 +205,7 @@
timeStamp: Date.now()
};
var response = safari.self.tab.canLoad(e, details);
if(!response) {
if(response === false) {
e.preventDefault();
}
};