mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Reomving now obsolete Safari code base
See README.md file: https://github.com/gorhill/uBlock/tree/master/platform/safari/README.md
This commit is contained in:
parent
917f3620e0
commit
149b5cf59c
14 changed files with 11 additions and 1580 deletions
|
@ -1,91 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Author</key>
|
||||
<string>Chris Aljoudi</string>
|
||||
<key>Builder Version</key>
|
||||
<string>534.57.2</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>{name}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>net.gorhill.uBlock</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{version}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{buildNumber}</string>
|
||||
<key>Chrome</key>
|
||||
<dict>
|
||||
<key>Database Quota</key>
|
||||
<real>104857600</real>
|
||||
<key>Global Page</key>
|
||||
<string>background.html</string>
|
||||
<key>Popovers</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>Filename</key>
|
||||
<string>popup.html</string>
|
||||
<key>Identifier</key>
|
||||
<string>popover</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Toolbar Items</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>Identifier</key>
|
||||
<string>toolbarItem</string>
|
||||
<key>Image</key>
|
||||
<string>img/browsericons/safari-icon16.png</string>
|
||||
<key>Label</key>
|
||||
<string>{name}</string>
|
||||
<key>Palette Label</key>
|
||||
<string>{name}</string>
|
||||
<key>Popover</key>
|
||||
<string>popover</string>
|
||||
<key>Tool Tip</key>
|
||||
<string>{name} {version}</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>Content</key>
|
||||
<dict>
|
||||
<key>Scripts</key>
|
||||
<dict>
|
||||
<key>End</key>
|
||||
<array>
|
||||
<string>js/contentscript-end.js</string>
|
||||
</array>
|
||||
<key>Start</key>
|
||||
<array>
|
||||
<string>js/vapi-client.js</string>
|
||||
<string>js/contentscript-start.js</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>Whitelist</key>
|
||||
<array>
|
||||
<string>http://*/*</string>
|
||||
<string>https://*/*</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>Description</key>
|
||||
<string>{description}</string>
|
||||
<key>ExtensionInfoDictionaryVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>Permissions</key>
|
||||
<dict>
|
||||
<key>Website Access</key>
|
||||
<dict>
|
||||
<key>Include Secure Pages</key>
|
||||
<true/>
|
||||
<key>Level</key>
|
||||
<string>All</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Update Manifest URL</key>
|
||||
<string>https://chrismatic.io/ublock/Update.plist</string>
|
||||
<key>Website</key>
|
||||
<string>https://chrismatic.io/</string>
|
||||
</dict>
|
||||
</plist>
|
11
platform/safari/README.md
Normal file
11
platform/safari/README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Safari platform
|
||||
|
||||
The Safari platform does not support the WebExtensions
|
||||
framwork and thus is no longer supported. Consequently
|
||||
the code base has been removed.
|
||||
|
||||
The last commit which contains the code is
|
||||
917f3620e0c08b722bbd4d400bca2735d9f6975f.
|
||||
|
||||
You can browse the last state of the removed code base at
|
||||
<https://github.com/gorhill/uBlock/tree/917f3620e0c08b722bbd4d400bca2735d9f6975f/platform/safari>.
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<array>
|
||||
<dict>
|
||||
<key>DefaultValue</key>
|
||||
<false/>
|
||||
<key>FalseValue</key>
|
||||
<false/>
|
||||
<key>Key</key>
|
||||
<string>open_prefs</string>
|
||||
<key>Secure</key>
|
||||
<false/>
|
||||
<key>Title</key>
|
||||
<string>Click to see the Preferences</string>
|
||||
<key>TrueValue</key>
|
||||
<true/>
|
||||
<key>Type</key>
|
||||
<string>CheckBox</string>
|
||||
</dict>
|
||||
</array>
|
||||
</plist>
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Extension Updates</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>net.gorhill.uBlock</string>
|
||||
<key>Developer Identifier</key>
|
||||
<string>96G4BAKDQ9</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{version}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{buildNumber}</string>
|
||||
<key>URL</key>
|
||||
<string>https://chrismatic.io/ublock/ublock-latest.safariextz</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
Before Width: | Height: | Size: 113 B |
|
@ -1,4 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" viewBox="0 0 97.6 97.6">
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<path d="M65.7,30.3c-0.3,6.1-0.1,12.3-0.1,18.4S65.6,61,65.7,67.1c0.1,2.5-0.5,3.8-3.3,4.3c-4.3,0.8-8.7,1.5-13.1,1.5 c-9.5,0-15.1-4.4-16.6-13.8C31,49,32.3,38.7,32,28.4c0-1.6,0.8-1.9,2.2-2c6.5-0.6,6.6-0.5,6.6,6c0,6.8-0.1,13.6,0.1,20.4 c0.2,9.4,3.4,12,12.7,11.3c2.7-0.2,3.3-1.1,3.3-3.6c-0.1-10,0.2-20-0.2-30c-0.1-3.9,1.5-4.2,4.7-4.2C64.4,26.3,65.9,26.7,65.7,30.3z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 557 B |
Binary file not shown.
Before Width: | Height: | Size: 161 B |
Binary file not shown.
Before Width: | Height: | Size: 239 B |
|
@ -1,4 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" viewBox="0 0 16 16">
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<path d="M8,16c-1,0-2,0-3,0c-0.3,0-0.6-0.1-0.8-0.3c-1.3-1.3-2.5-2.6-3.8-3.9C0.1,11.6,0,11.4,0,11C0,9,0,7,0,4.9 c0-0.3,0.1-0.5,0.3-0.7c1.3-1.3,2.6-2.6,3.9-3.9C4.4,0.1,4.6,0,4.9,0C7,0,9,0,11,0c0.3,0,0.5,0.1,0.8,0.3c1.3,1.3,2.6,2.6,3.9,3.9 C15.9,4.4,16,4.6,16,4.9c0,2.1,0,4.1,0,6.2c0,0.3-0.1,0.5-0.3,0.7c-1.3,1.3-2.6,2.6-3.9,3.9C11.5,15.9,11.3,16,11,16 C10,16,9,16,8,16z M10.8,8c0-1,0-2,0-3c0-0.6-0.2-0.7-0.7-0.7S9.3,4.4,9.3,5c0.1,1.6,0,3.3,0,4.9c0,0.4-0.1,0.6-0.5,0.6 c-1.5,0.1-2.1-0.3-2.1-1.9c0-1.1,0-2.2,0-3.3c0-1.1,0-1.1-1.1-1c-0.2,0-0.4,0.1-0.4,0.3c0,1.7-0.2,3.4,0.1,5 c0.2,1.5,1.2,2.2,2.7,2.3c0.7,0,1.4-0.1,2.1-0.2c0.5-0.1,0.5-0.3,0.5-0.7C10.7,10,10.8,9,10.8,8z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 858 B |
Binary file not shown.
Before Width: | Height: | Size: 308 B |
File diff suppressed because one or more lines are too long
|
@ -1,343 +0,0 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock - a browser extension to block requests.
|
||||
Copyright (C) 2015 The uBlock authors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
/******************************************************************************/
|
||||
// For non background pages
|
||||
|
||||
(function(self) {
|
||||
'use strict';
|
||||
var vAPI = self.vAPI = self.vAPI || {};
|
||||
if(vAPI.vapiClientInjected) {
|
||||
return;
|
||||
}
|
||||
var safari;
|
||||
if(typeof self.safari === "undefined") {
|
||||
safari = self.top.safari;
|
||||
}
|
||||
else {
|
||||
safari = self.safari;
|
||||
}
|
||||
vAPI.vapiClientInjected = true;
|
||||
vAPI.safari = true;
|
||||
vAPI.sessionId = String.fromCharCode(Date.now() % 25 + 97) +
|
||||
Math.random().toString(36).slice(2);
|
||||
/******************************************************************************/
|
||||
vAPI.shutdown = (function() {
|
||||
var jobs = [];
|
||||
|
||||
var add = function(job) {
|
||||
jobs.push(job);
|
||||
};
|
||||
|
||||
var exec = function() {
|
||||
//console.debug('Shutting down...');
|
||||
var job;
|
||||
while ( job = jobs.pop() ) {
|
||||
job();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
add: add,
|
||||
exec: exec
|
||||
};
|
||||
})();
|
||||
/******************************************************************************/
|
||||
var messagingConnector = function(response) {
|
||||
if(!response) {
|
||||
return;
|
||||
}
|
||||
var channels = vAPI.messaging.channels;
|
||||
var channel, listener;
|
||||
if(response.broadcast === true && !response.channelName) {
|
||||
for(channel in channels) {
|
||||
if(channels.hasOwnProperty(channel) === false) {
|
||||
continue;
|
||||
}
|
||||
listener = channels[channel].listener;
|
||||
if(typeof listener === 'function') {
|
||||
listener(response.msg);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(response.requestId) {
|
||||
listener = vAPI.messaging.listeners[response.requestId];
|
||||
delete vAPI.messaging.listeners[response.requestId];
|
||||
delete response.requestId;
|
||||
}
|
||||
if(!listener) {
|
||||
channel = channels[response.channelName];
|
||||
listener = channel && channel.listener;
|
||||
}
|
||||
if(typeof listener === 'function') {
|
||||
listener(response.msg);
|
||||
}
|
||||
};
|
||||
/******************************************************************************/
|
||||
// Relevant?
|
||||
// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/MessagesandProxies/MessagesandProxies.html#//apple_ref/doc/uid/TP40009977-CH14-SW12
|
||||
vAPI.messaging = {
|
||||
channels: {},
|
||||
listeners: {},
|
||||
requestId: 1,
|
||||
setup: function() {
|
||||
this.connector = function(msg) {
|
||||
// messages from the background script are sent to every frame,
|
||||
// so we need to check the vAPI.sessionId to accept only
|
||||
// what is meant for the current context
|
||||
if(msg.name === vAPI.sessionId || msg.name === 'broadcast') {
|
||||
messagingConnector(msg.message);
|
||||
}
|
||||
};
|
||||
safari.self.addEventListener('message', this.connector, false);
|
||||
this.channels['vAPI'] = {
|
||||
listener: function(msg) {
|
||||
if(msg.cmd === 'injectScript' && msg.details.code) {
|
||||
Function(msg.details.code).call(self);
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
close: function() {
|
||||
if(this.connector) {
|
||||
safari.self.removeEventListener('message', this.connector, false);
|
||||
this.connector = null;
|
||||
this.channels = {};
|
||||
this.listeners = {};
|
||||
}
|
||||
},
|
||||
channel: function(channelName, callback) {
|
||||
if(!channelName) {
|
||||
return;
|
||||
}
|
||||
this.channels[channelName] = {
|
||||
channelName: channelName,
|
||||
listener: typeof callback === 'function' ? callback : null,
|
||||
send: function(message, callback) {
|
||||
if(!vAPI.messaging.connector) {
|
||||
vAPI.messaging.setup();
|
||||
}
|
||||
message = {
|
||||
channelName: this.channelName,
|
||||
msg: message
|
||||
};
|
||||
if(callback) {
|
||||
message.requestId = vAPI.messaging.requestId++;
|
||||
vAPI.messaging.listeners[message.requestId] = callback;
|
||||
}
|
||||
// popover content doesn't know messaging...
|
||||
if(safari.extension.globalPage) {
|
||||
if(!safari.self.visible) {
|
||||
return;
|
||||
}
|
||||
safari.extension.globalPage.contentWindow.vAPI.messaging.onMessage({
|
||||
name: vAPI.sessionId,
|
||||
message: message,
|
||||
target: {
|
||||
page: {
|
||||
dispatchMessage: function(name, msg) {
|
||||
messagingConnector(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
safari.self.tab.dispatchMessage(vAPI.sessionId, message);
|
||||
}
|
||||
},
|
||||
close: function() {
|
||||
delete vAPI.messaging.channels[this.channelName];
|
||||
}
|
||||
};
|
||||
return this.channels[channelName];
|
||||
}
|
||||
};
|
||||
|
||||
// The following code should run only in content pages
|
||||
if(location.protocol === "safari-extension:" || typeof safari !== "object") {
|
||||
return;
|
||||
}
|
||||
|
||||
var frameId = window === window.top ? 0 : Date.now() % 1E5;
|
||||
var parentFrameId = (frameId ? 0 : -1);
|
||||
|
||||
// Helper event to message background,
|
||||
// and helper anchor element
|
||||
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, {
|
||||
url: location.href,
|
||||
type: "main_frame"
|
||||
});
|
||||
}
|
||||
var nodeTypes = {
|
||||
"frame": "sub_frame",
|
||||
"iframe": "sub_frame",
|
||||
"script": "script",
|
||||
"img": "image",
|
||||
"input": "image",
|
||||
"object": "object",
|
||||
"embed": "object",
|
||||
"link": "stylesheet"
|
||||
};
|
||||
var shouldBlockDetailedRequest = function(details) {
|
||||
linkHelper.href = details.url;
|
||||
details.url = linkHelper.href;
|
||||
details.frameId = frameId;
|
||||
details.parentFrameId = parentFrameId;
|
||||
details.timeStamp = Date.now();
|
||||
return !(safari.self.tab.canLoad(beforeLoadEvent, details));
|
||||
};
|
||||
var onBeforeLoad = function(e) {
|
||||
if(firstMutation !== false) {
|
||||
firstMutation();
|
||||
}
|
||||
linkHelper.href = e.url;
|
||||
if(linkHelper.protocol.charCodeAt(0) !== 104) { // h = 104
|
||||
return;
|
||||
}
|
||||
var details = {
|
||||
url: linkHelper.href,
|
||||
type: nodeTypes[e.target.nodeName.toLowerCase()] || "other",
|
||||
// tabId is determined in the background script
|
||||
frameId: frameId,
|
||||
parentFrameId: parentFrameId,
|
||||
timeStamp: Date.now()
|
||||
};
|
||||
var response = safari.self.tab.canLoad(e, details);
|
||||
if(response === false) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
document.addEventListener("beforeload", onBeforeLoad, true);
|
||||
|
||||
// Block popups, intercept XHRs
|
||||
var firstMutation = function() {
|
||||
document.removeEventListener("DOMContentLoaded", firstMutation, true);
|
||||
firstMutation = false;
|
||||
document.addEventListener(vAPI.sessionId, function(e) {
|
||||
if(shouldBlockDetailedRequest(e.detail)) {
|
||||
e.detail.url = false;
|
||||
}
|
||||
}, true);
|
||||
var tmpJS = document.createElement("script");
|
||||
var tmpScript = "\
|
||||
(function() {\
|
||||
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,\
|
||||
xo = XMLHttpRequest.prototype.open,\
|
||||
img = Image;\
|
||||
Image = function() {\
|
||||
var x = new img();\
|
||||
Object.defineProperty(x, 'src', {\
|
||||
get: function() {\
|
||||
return x.getAttribute('src');\
|
||||
},\
|
||||
set: function(val) {\
|
||||
x.setAttribute('src', block(val, 'image') ? 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=' : val);\
|
||||
}\
|
||||
});\
|
||||
return x;\
|
||||
};\
|
||||
open = function(u) {\
|
||||
return block(u, 'popup') ? null : wo.apply(this, arguments);\
|
||||
};\
|
||||
XMLHttpRequest.prototype.open = function(m, u) {\
|
||||
if(block(u, 'xmlhttprequest')) {throw 'InvalidAccessError'; return;}\
|
||||
else {xo.apply(this, arguments); return;}\
|
||||
};";
|
||||
if(frameId === 0) {
|
||||
tmpScript += "\
|
||||
var pS = history.pushState,\
|
||||
rS = history.replaceState,\
|
||||
onpopstate = function(e) {\
|
||||
if(!e || e.state !== null) {\
|
||||
block(location.href, 'popstate');\
|
||||
}\
|
||||
};\
|
||||
window.addEventListener('popstate', onpopstate, true);\
|
||||
history.pushState = function() {\
|
||||
var r = pS.apply(this, arguments);\
|
||||
onpopstate();\
|
||||
return r;\
|
||||
};\
|
||||
history.replaceState = function() {\
|
||||
var r = rS.apply(this, arguments);\
|
||||
onpopstate();\
|
||||
return r;\
|
||||
};";
|
||||
}
|
||||
tmpScript += "})();";
|
||||
tmpJS.textContent = tmpScript;
|
||||
document.documentElement.removeChild(document.documentElement.appendChild(tmpJS));
|
||||
};
|
||||
document.addEventListener("DOMContentLoaded", firstMutation, true);
|
||||
|
||||
var onContextMenu = function(e) {
|
||||
var target = e.target;
|
||||
var tagName = target.tagName.toLowerCase();
|
||||
var details = {
|
||||
tagName: tagName,
|
||||
pageUrl: location.href,
|
||||
insideFrame: window !== window.top
|
||||
};
|
||||
details.editable = (tagName === "textarea" || tagName === "input");
|
||||
if(target.hasOwnProperty("checked")) {
|
||||
details.checked = target.checked;
|
||||
}
|
||||
if(tagName === "a") {
|
||||
details.linkUrl = target.href;
|
||||
}
|
||||
if(target.hasOwnProperty("src")) {
|
||||
details.srcUrl = target.src;
|
||||
if(tagName === "img") {
|
||||
details.mediaType = "image";
|
||||
} else if(tagName === "video" || tagName === "audio") {
|
||||
details.mediaType = tagName;
|
||||
}
|
||||
}
|
||||
safari.self.tab.setContextMenuEventUserInfo(e, details);
|
||||
};
|
||||
self.addEventListener("contextmenu", onContextMenu, true);
|
||||
})(this);
|
||||
|
||||
/******************************************************************************/
|
|
@ -1,148 +0,0 @@
|
|||
/*******************************************************************************
|
||||
|
||||
µBlock - a browser extension to block requests.
|
||||
Copyright (C) 2014 The µBlock authors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
// For background page or non-background pages
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
var vAPI = self.vAPI = self.vAPI || {};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// http://www.w3.org/International/questions/qa-scripts#directions
|
||||
|
||||
var setScriptDirection = function(language) {
|
||||
document.body.setAttribute(
|
||||
'dir',
|
||||
['ar', 'he', 'fa', 'ps', 'ur'].indexOf(language) !== -1 ? 'rtl' : 'ltr'
|
||||
);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.download = function(details) {
|
||||
if ( !details.url ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var a = document.createElement('a');
|
||||
|
||||
if ( 'download' in a ) {
|
||||
a.href = details.url;
|
||||
a.setAttribute('download', details.filename || '');
|
||||
a.dispatchEvent(new MouseEvent('click'));
|
||||
return;
|
||||
}
|
||||
var request = {
|
||||
what: 'gotoURL',
|
||||
details: {
|
||||
url: details.url,
|
||||
index: -1
|
||||
}
|
||||
};
|
||||
|
||||
if ( vAPI.isMainProcess ) {
|
||||
vAPI.tabs.open(request.details);
|
||||
return;
|
||||
}
|
||||
|
||||
var messager = vAPI.messaging.channel('_download');
|
||||
messager.send(request);
|
||||
messager.close();
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.insertHTML = function(node, html) {
|
||||
node.innerHTML = html;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.getURL = function(path) {
|
||||
return safari.extension.baseURI + path;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Supported languages
|
||||
// First language is the default
|
||||
|
||||
vAPI.i18nData = [
|
||||
'en', 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'es', 'et', 'fa', 'fi',
|
||||
'fil', 'fr', 'he', 'hi', 'hr', 'hu', 'id', 'it', 'ja', 'ko', 'lt', 'lv',
|
||||
'mr', 'nb', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sl', 'sq', 'sr',
|
||||
'sv', 'te', 'tr', 'uk', 'vi', 'zh-CN', 'zh-TW'
|
||||
];
|
||||
|
||||
vAPI.i18n = navigator.language;
|
||||
|
||||
if ( vAPI.i18nData.indexOf(vAPI.i18n) === -1 ) {
|
||||
vAPI.i18n = vAPI.i18n.slice(0, 2);
|
||||
|
||||
if ( vAPI.i18nData.indexOf(vAPI.i18n) === -1 ) {
|
||||
vAPI.i18n = vAPI.i18nData[0];
|
||||
}
|
||||
}
|
||||
|
||||
setScriptDirection(vAPI.i18n);
|
||||
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.overrideMimeType('application/json;charset=utf-8');
|
||||
xhr.open('GET', './_locales/' + vAPI.i18n + '.json', false);
|
||||
xhr.send();
|
||||
vAPI.i18nData = JSON.parse(xhr.responseText);
|
||||
|
||||
vAPI.i18n = function(s) {
|
||||
return this.i18nData[s] || '';
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.closePopup = function() {
|
||||
var popover = safari.extension.popovers[0];
|
||||
if ( popover ) {
|
||||
popover.hide();
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
Number.prototype._toLocaleString = Number.prototype.toLocaleString;
|
||||
Number.prototype.toLocaleString = function() {
|
||||
// some parts expect comma-formatting; Safari doesn't do it automatically
|
||||
return this._toLocaleString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// A localStorage-like object which should be accessible from the
|
||||
// background page or auxiliary pages.
|
||||
// This storage is optional, but it is nice to have, for a more polished user
|
||||
// experience.
|
||||
|
||||
vAPI.localStorage = self.localStorage;
|
||||
|
||||
})();
|
|
@ -1,52 +0,0 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock - a browser extension to block requests.
|
||||
Copyright (C) 2015 The uBlock authors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var DF_ENABLED_CLASS = "dfEnabled";
|
||||
|
||||
var onLoaded = function() {
|
||||
var _toggle = DOMTokenList.prototype.toggle;
|
||||
DOMTokenList.prototype.toggle = function(className) {
|
||||
_toggle.apply(this, arguments);
|
||||
if(className === DF_ENABLED_CLASS) {
|
||||
setTimeout(updateSize, 0);
|
||||
}
|
||||
};
|
||||
var body = document.body, popover = safari.self;
|
||||
|
||||
var panes = document.getElementById("panes"),
|
||||
powerAndStatsPane = panes.children[0],
|
||||
dfPane = panes.children[1];
|
||||
|
||||
var updateSize = function() {
|
||||
var dfEnabled = panes.classList.contains(DF_ENABLED_CLASS);
|
||||
popover.width = powerAndStatsPane.clientWidth + (dfEnabled ? dfPane.clientWidth : 0);
|
||||
popover.height = body.clientHeight;
|
||||
};
|
||||
|
||||
body.style.setProperty("width", "100%");
|
||||
panes.style.setProperty("width", "100%");
|
||||
dfPane.style.setProperty("display", "inline-block", "important");
|
||||
setTimeout(updateSize, 0);
|
||||
};
|
||||
window.addEventListener("load", onLoaded);
|
||||
})();
|
Loading…
Reference in a new issue