Firefox: implement toolbar button and popup

This commit is contained in:
Deathamns 2014-12-16 13:44:34 +01:00
parent e4329b7dfe
commit cb5d860725
15 changed files with 341 additions and 126 deletions

View file

@ -87,7 +87,7 @@ var messagingConnector = function(response) {
/******************************************************************************/ /******************************************************************************/
var uniqueId = function() { var uniqueId = function() {
return parseInt(Math.random() * 1e10, 10).toString(36); return Math.random().toString(36).slice(2);
}; };
/******************************************************************************/ /******************************************************************************/

View file

@ -39,9 +39,7 @@ function shutdown(data, reason) {
} }
} }
function install() { // https://bugzil.la/719376
// https://bugzil.la/719376 function install() Services.strings.flushBundles();
Services.strings.flushBundles();
}
function uninstall() {} function uninstall() {}

View file

@ -1,14 +1,18 @@
/* global Services, Components, XPCOMUtils */ /* global Services, Components, XPCOMUtils */
/* exported EXPORTED_SYMBOLS, isTabbed */
'use strict'; 'use strict';
var EXPORTED_SYMBOLS = ['contentPolicy', 'docObserver']; this.EXPORTED_SYMBOLS = ['contentPolicy', 'docObserver'];
Components.utils['import']('resource://gre/modules/Services.jsm'); Components.utils['import']('resource://gre/modules/Services.jsm');
Components.utils['import']('resource://gre/modules/XPCOMUtils.jsm'); Components.utils['import']('resource://gre/modules/XPCOMUtils.jsm');
const Ci = Components.interfaces, appName = 'ublock'; const Ci = Components.interfaces;
var appName;
try { throw new Error; } catch (ex) {
appName = ex.fileName.match(/:\/\/([^\/]+)/)[1];
}
let getMessager = function(win) { let getMessager = function(win) {
try { try {
@ -33,9 +37,10 @@ let getMessager = function(win) {
let contentPolicy = { let contentPolicy = {
classDescription: 'ContentPolicy implementation', classDescription: 'ContentPolicy implementation',
classID: Components.ID('{e6d173c8-8dbf-4189-a6fd-189e8acffd27}'), classID: Components.ID('{e6d173c8-8dbf-4189-a6fd-189e8acffd27}'),
contractID: '@ublock/content-policy;1', contractID: '@' + appName + '/content-policy;1',
ACCEPT: Ci.nsIContentPolicy.ACCEPT, ACCEPT: Ci.nsIContentPolicy.ACCEPT,
REJECT: Ci.nsIContentPolicy.REJECT_REQUEST, REJECT: Ci.nsIContentPolicy.REJECT_REQUEST,
requestMessageName: appName + ':onBeforeRequest',
get componentRegistrar() { get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar); return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
}, },
@ -89,7 +94,7 @@ let contentPolicy = {
return this.ACCEPT; return this.ACCEPT;
} }
let result = getMessager(win).sendSyncMessage('ublock:onBeforeRequest', { let result = getMessager(win).sendSyncMessage(this.requestMessageName, {
url: location.spec, url: location.spec,
type: type, type: type,
tabId: -1, tabId: -1,
@ -105,7 +110,7 @@ let contentPolicy = {
}; };
let docObserver = { let docObserver = {
contentBaseURI: 'chrome://ublock/content/js/', contentBaseURI: 'chrome://' + appName + '/content/js/',
initContext: function(win, sandbox) { initContext: function(win, sandbox) {
let messager = getMessager(win); let messager = getMessager(win);
@ -115,6 +120,8 @@ let docObserver = {
wantComponents: false, wantComponents: false,
wantXHRConstructor: false wantXHRConstructor: false
}); });
win.self = win;
} }
win.sendAsyncMessage = messager.sendAsyncMessage; win.sendAsyncMessage = messager.sendAsyncMessage;
@ -151,17 +158,12 @@ let docObserver = {
lss(this.contentBaseURI + 'vapi-client.js', win); lss(this.contentBaseURI + 'vapi-client.js', win);
lss(this.contentBaseURI + 'contentscript-start.js', win); lss(this.contentBaseURI + 'contentscript-start.js', win);
if (doc.readyState === 'interactive' || doc.readyState === 'complete') { let docReady = function(e) {
lss(this.contentBaseURI + 'contentscript-end.js', win); this.removeEventListener(e.type, docReady, true);
} lss(docObserver.contentBaseURI + 'contentscript-end.js', win);
else { };
let docReady = function(e) {
this.removeEventListener(e.type, docReady, true);
lss(docObserver.contentBaseURI + 'contentscript-end.js', win);
};
doc.addEventListener('DOMContentLoaded', docReady, true); doc.addEventListener('DOMContentLoaded', docReady, true);
}
} }
}; };

View file

@ -1,20 +1,27 @@
/* globals Services, sendAsyncMessage, addMessageListener, removeMessageListener */ /* globals Services, sendAsyncMessage, addMessageListener, removeMessageListener */
(function(frameScriptContext) {
'use strict'; 'use strict';
let appName = 'ublock'; let appName;
let listeners = {}; let listeners = {};
let frameModule = Components.utils['import']('chrome://' + appName + '/content/frameModule.js', {});
this.ublock_addMessageListener = function(id, fn) { try { throw new Error; } catch (ex) {
ublock_removeMessageListener(id); appName = ex.fileName.match(/:\/\/([^\/]+)/)[1];
}
Components.utils['import']('chrome://' + appName + '/content/frameModule.js', {});
frameScriptContext[appName + '_addMessageListener'] = function(id, fn) {
frameScriptContext[appName + '_removeMessageListener'](id);
listeners[id] = function(msg) { listeners[id] = function(msg) {
fn(msg.data); fn(msg.data);
}; };
addMessageListener(id, listeners[id]); addMessageListener(id, listeners[id]);
}; };
this.ublock_removeMessageListener = function(id) { frameScriptContext[appName + '_removeMessageListener'] = function(id) {
if (listeners[id]) { if (listeners[id]) {
removeMessageListener(id, listeners[id]); removeMessageListener(id, listeners[id]);
} }
@ -27,3 +34,5 @@ addMessageListener(appName + ':broadcast', function(msg) {
listeners[id](msg); listeners[id](msg);
} }
}); });
})(this);

View file

@ -17,7 +17,7 @@
<targetApplication> <targetApplication>
<r:Description> <r:Description>
<id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id> <id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id>
<minVersion>24.0</minVersion> <minVersion>29.0</minVersion>
<maxVersion>37.0</maxVersion> <maxVersion>37.0</maxVersion>
</r:Description> </r:Description>
</targetApplication> </targetApplication>
@ -26,7 +26,7 @@
<targetApplication> <targetApplication>
<r:Description> <r:Description>
<id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</id> <id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</id>
<minVersion>2.21</minVersion> <minVersion>2.26</minVersion>
<maxVersion>2.34</maxVersion> <maxVersion>2.34</maxVersion>
</r:Description> </r:Description>
</targetApplication> </targetApplication>

View file

@ -19,7 +19,7 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
/* global Services */ /* global Services, CustomizableUI */
// For background page // For background page
@ -34,26 +34,30 @@
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu['import']('resource://gre/modules/Services.jsm'); Cu['import']('resource://gre/modules/Services.jsm');
Cu['import']('resource:///modules/CustomizableUI.jsm');
/******************************************************************************/ /******************************************************************************/
self.vAPI = self.vAPI || {}; self.vAPI = self.vAPI || {};
vAPI.firefox = true; vAPI.firefox = true;
/******************************************************************************/ /******************************************************************************/
vAPI.app = { vAPI.app = {
name: 'µBlock', name: 'µBlock',
cleanName: 'ublock', version: '0.7.2.0',
version: '0.7.2.0' cleanName: location.host
}; };
/******************************************************************************/ /******************************************************************************/
vAPI.app.restart = function() { vAPI.app.restart = function() {};
}; /******************************************************************************/
// list of things that needs to be destroyed when disabling the extension
vAPI.unload = [];
/******************************************************************************/ /******************************************************************************/
@ -76,10 +80,11 @@ var SQLite = {
'CREATE TABLE IF NOT EXISTS settings' + 'CREATE TABLE IF NOT EXISTS settings' +
'(name TEXT PRIMARY KEY NOT NULL, value TEXT);' '(name TEXT PRIMARY KEY NOT NULL, value TEXT);'
); );
},
close: function() { vAPI.unload.push(function() {
this.run('VACUUM'); SQLite.run('VACUUM');
this.db.asyncClose(); SQLite.db.asyncClose();
});
}, },
run: function(query, values, callback) { run: function(query, values, callback) {
if (!this.db) { if (!this.db) {
@ -233,10 +238,15 @@ vAPI.storage = {
var windowWatcher = { var windowWatcher = {
onTabClose: function(e) { onTabClose: function(e) {
vAPI.tabs.onClosed(vAPI.tabs.getTabId(e.target)); var tabId = vAPI.tabs.getTabId(e.target);
vAPI.tabs.onClosed(tabId);
delete vAPI.tabIcons[tabId];
}, },
onTabSelect: function() { onTabSelect: function(e) {
// vAPI.setIcon(); vAPI.setIcon(
vAPI.tabs.getTabId(e.target),
e.target.ownerDocument.defaultView
);
}, },
onLoad: function(e) { onLoad: function(e) {
if (e) { if (e) {
@ -259,20 +269,10 @@ var windowWatcher = {
tC.addEventListener('TabClose', windowWatcher.onTabClose); tC.addEventListener('TabClose', windowWatcher.onTabClose);
tC.addEventListener('TabSelect', windowWatcher.onTabSelect); tC.addEventListener('TabSelect', windowWatcher.onTabSelect);
vAPI.toolbarButton.add(this.document);
// when new window is opened TabSelect doesn't run on the selected tab? // when new window is opened TabSelect doesn't run on the selected tab?
}, },
unregister: function() {
Services.ww.unregisterNotification(this);
for (var win of vAPI.tabs.getWindows()) {
win.removeEventListener('load', this.onLoad);
win.gBrowser.removeTabsProgressListener(tabsProgressListener);
var tC = win.gBrowser.tabContainer;
tC.removeEventListener('TabClose', this.onTabClose);
tC.removeEventListener('TabSelect', this.onTabSelect);
}
},
observe: function(win, topic) { observe: function(win, topic) {
if (topic === 'domwindowopened') { if (topic === 'domwindowopened') {
win.addEventListener('load', this.onLoad); win.addEventListener('load', this.onLoad);
@ -320,10 +320,35 @@ vAPI.tabs.registerListeners = function() {
Services.ww.registerNotification(windowWatcher); Services.ww.registerNotification(windowWatcher);
// already opened windows
for (var win of this.getWindows()) { for (var win of this.getWindows()) {
windowWatcher.onLoad.call(win); windowWatcher.onLoad.call(win);
} }
vAPI.toolbarButton.init();
vAPI.unload.push(function() {
Services.ww.unregisterNotification(windowWatcher);
for (var win of vAPI.tabs.getWindows()) {
vAPI.toolbarButton.remove(win.document);
win.removeEventListener('load', windowWatcher.onLoad);
win.gBrowser.removeTabsProgressListener(tabsProgressListener);
var tC = win.gBrowser.tabContainer;
tC.removeEventListener('TabClose', windowWatcher.onTabClose);
tC.removeEventListener('TabSelect', windowWatcher.onTabSelect);
// close extension tabs
for (var tab of win.gBrowser.tabs) {
var URI = tab.linkedBrowser.currentURI;
if (URI.scheme === 'chrome' && URI.host === vAPI.app.cleanName) {
win.gBrowser.removeTab(tab);
}
}
}
});
}; };
/******************************************************************************/ /******************************************************************************/
@ -513,21 +538,164 @@ vAPI.tabs.close = function(tabIds) {
/******************************************************************************/ /******************************************************************************/
/*vAPI.tabs.injectScript = function(tabId, details, callback) { vAPI.tabs.injectScript = function(tabId, details, callback) {
};*/ };
/******************************************************************************/ /******************************************************************************/
vAPI.setIcon = function() { vAPI.tabIcons = { /*tabId: {badge: 0, img: dict}*/ };
vAPI.setIcon = function(tabId, img, badge) {
var curWin = badge === undefined ? img : Services.wm.getMostRecentWindow('navigator:browser');
var curTabId = vAPI.tabs.getTabId(curWin.gBrowser.selectedTab);
// from 'TabSelect' event
if (tabId === undefined) {
tabId = curTabId;
}
else if (badge !== undefined) {
vAPI.tabIcons[tabId] = {
badge: badge === '>1K' ? '1k+' : badge,
img: img && img[19] && img[19].replace(/19(-off)?\.png$/, '16$1.svg')
};
}
if (tabId !== curTabId) {
return;
}
var button = curWin.document.getElementById(vAPI.toolbarButton.widgetId);
var icon = vAPI.tabIcons[tabId];
button.setAttribute('badge', icon && icon.badge || '');
button.style.listStyleImage = 'url(' + vAPI.getURL(icon && icon.img || 'img/browsericons/icon16-off.svg') + ')';
};
/******************************************************************************/
vAPI.toolbarButton = {
widgetId: vAPI.app.cleanName + '-button',
panelId: vAPI.app.cleanName + '-panel'
};
/******************************************************************************/
vAPI.toolbarButton.init = function() {
CustomizableUI.createWidget({
id: this.widgetId,
type: 'view',
viewId: this.panelId,
defaultArea: CustomizableUI.AREA_NAVBAR,
label: vAPI.app.name,
tooltiptext: vAPI.app.name,
onViewShowing: function(e) {
e.target.firstChild.setAttribute('src', vAPI.getURL('popup.html'));
},
onViewHiding: function(e) {
e.target.firstChild.setAttribute('src', 'about:blank');
}
});
var doc = Services.wm.getMostRecentWindow('navigator:browser').document;
var button = doc.getElementById(this.widgetId);
button.style.listStyleImage = 'url(' + vAPI.getURL('img/icon16.svg') + ')';
if (!this.styleURI) {
var css = encodeURIComponent([
'#' + this.widgetId + '[badge]:not([badge=""])::after {',
'position: absolute; color: #fff; background: #666;',
'content: attr(badge); font-size: 9px; font-weight: bold;',
'padding: 1px 2px; margin-left: -16px; margin-top: 3px }'
].join(''));
this.styleURI = Services.io.newURI('data:text/css,' + css, null, null);
}
var sss = Cc['@mozilla.org/content/style-sheet-service;1']
.getService(Ci.nsIStyleSheetService);
sss.loadAndRegisterSheet(this.styleURI, sss.USER_SHEET);
vAPI.unload.push(function() {
sss.unregisterSheet(this.styleURI, sss.USER_SHEET);
CustomizableUI.createWidget(this.widgetId);
}.bind(this));
};
/******************************************************************************/
// it runs with windowWatcher when a window is opened
// vAPI.tabs.registerListeners initializes it
vAPI.toolbarButton.add = function(doc) {
var panel = doc.createElement('panelview');
panel.id = this.panelId;
var iframe = panel.appendChild(doc.createElement('iframe'));
iframe.setAttribute('type', 'content');
panel.style.cssText = iframe.style.cssText
= 'width: 180px; height: 310px; transition: width .1s, height .1s';
doc.getElementById('PanelUI-multiView')
.appendChild(panel)
.appendChild(iframe);
var updateTimer = null;
var delayedResize = function() {
if (updateTimer) {
return;
}
updateTimer = setTimeout(resizePopup, 20);
};
var resizePopup = function() {
var panelStyle = panel.style;
var body = iframe.contentDocument.body;
panelStyle.width = iframe.style.width = body.clientWidth + 'px';
panelStyle.height = iframe.style.height = body.clientHeight + 'px';
updateTimer = null;
};
var onPopupReady = function() {
if (!this.contentWindow
|| this.contentWindow.location.host !== vAPI.app.cleanName) {
return;
}
var mutObs = this.contentWindow.MutationObserver;
(new mutObs(delayedResize)).observe(this.contentDocument, {
childList: true,
attributes: true,
characterData: true,
subtree: true
});
delayedResize();
};
iframe.addEventListener('load', onPopupReady, true);
};
/******************************************************************************/
vAPI.toolbarButton.remove = function(doc) {
var panel = doc.getElementById(this.panelId);
panel.parentNode.removeChild(panel);
doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils).removeSheet(this.styleURI, 1);
}; };
/******************************************************************************/ /******************************************************************************/
vAPI.messaging = { vAPI.messaging = {
gmm: Cc['@mozilla.org/globalmessagemanager;1'].getService(Ci.nsIMessageListenerManager), get globalMessageManager() {
frameScript: 'chrome://' + vAPI.app.cleanName + '/content/frameScript.js', return Cc['@mozilla.org/globalmessagemanager;1']
.getService(Ci.nsIMessageListenerManager);
},
frameScript: vAPI.getURL('frameScript.js'),
listeners: {}, listeners: {},
defaultHandler: null, defaultHandler: null,
NOOPFUNC: function(){}, NOOPFUNC: function(){},
@ -536,10 +704,6 @@ vAPI.messaging = {
/******************************************************************************/ /******************************************************************************/
vAPI.messaging.gmm.loadFrameScript(vAPI.messaging.frameScript, true);
/******************************************************************************/
vAPI.messaging.listen = function(listenerName, callback) { vAPI.messaging.listen = function(listenerName, callback) {
this.listeners[listenerName] = callback; this.listeners[listenerName] = callback;
}; };
@ -548,6 +712,15 @@ vAPI.messaging.listen = function(listenerName, callback) {
vAPI.messaging.onMessage = function(request) { vAPI.messaging.onMessage = function(request) {
var messageManager = request.target.messageManager; var messageManager = request.target.messageManager;
if (!messageManager) {
// Message came from a popup, and its message manager is not usable.
// So instead we broadcast to the parent window.
messageManager = request.target
.webNavigation.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler.ownerDocument.defaultView.messageManager;
}
var listenerId = request.data.portName.split('|'); var listenerId = request.data.portName.split('|');
var requestId = request.data.requestId; var requestId = request.data.requestId;
var portName = listenerId[1]; var portName = listenerId[1];
@ -556,14 +729,18 @@ vAPI.messaging.onMessage = function(request) {
var callback = vAPI.messaging.NOOPFUNC; var callback = vAPI.messaging.NOOPFUNC;
if ( requestId !== undefined ) { if ( requestId !== undefined ) {
callback = function(response) { callback = function(response) {
messageManager.sendAsyncMessage( var message = JSON.stringify({
listenerId, requestId: requestId,
JSON.stringify({ portName: portName,
requestId: requestId, msg: response !== undefined ? response : null
portName: portName, });
msg: response !== undefined ? response : null
}) if (messageManager.sendAsyncMessage) {
); messageManager.sendAsyncMessage(listenerId, message);
}
else {
messageManager.broadcastAsyncMessage(listenerId, message);
}
}; };
} }
@ -610,16 +787,28 @@ vAPI.messaging.setup = function(defaultHandler) {
} }
this.defaultHandler = defaultHandler; this.defaultHandler = defaultHandler;
this.gmm.addMessageListener( this.globalMessageManager.addMessageListener(
vAPI.app.cleanName + ':background', vAPI.app.cleanName + ':background',
this.onMessage this.onMessage
); );
this.globalMessageManager.loadFrameScript(vAPI.messaging.frameScript, true);
vAPI.unload.push(function() {
var gmm = vAPI.messaging.globalMessageManager;
gmm.removeDelayedFrameScript(vAPI.messaging.frameScript);
gmm.removeMessageListener(
vAPI.app.cleanName + ':background',
vAPI.messaging.onMessage
);
});
}; };
/******************************************************************************/ /******************************************************************************/
vAPI.messaging.broadcast = function(message) { vAPI.messaging.broadcast = function(message) {
this.gmm.broadcastAsyncMessage( this.globalMessageManager.broadcastAsyncMessage(
vAPI.app.cleanName + ':broadcast', vAPI.app.cleanName + ':broadcast',
JSON.stringify({broadcast: true, msg: message}) JSON.stringify({broadcast: true, msg: message})
); );
@ -627,20 +816,12 @@ vAPI.messaging.broadcast = function(message) {
/******************************************************************************/ /******************************************************************************/
vAPI.messaging.unload = function() { vAPI.net = {
this.gmm.removeMessageListener( beforeRequestMessageName: vAPI.app.cleanName + ':onBeforeRequest'
vAPI.app.cleanName + ':background',
this.onMessage
);
this.gmm.removeDelayedFrameScript(this.frameScript);
}; };
/******************************************************************************/ /******************************************************************************/
vAPI.net = {};
/******************************************************************************/
vAPI.net.registerListeners = function() { vAPI.net.registerListeners = function() {
var types = { var types = {
2: 'script', 2: 'script',
@ -677,20 +858,30 @@ vAPI.net.registerListeners = function() {
return false; return false;
}; };
vAPI.messaging.gmm.addMessageListener( vAPI.messaging.globalMessageManager.addMessageListener(
vAPI.app.cleanName + ':onBeforeRequest', this.beforeRequestMessageName,
this.onBeforeRequest this.onBeforeRequest
); );
vAPI.unload.push(function() {
vAPI.messaging.globalMessageManager.removeMessageListener(
vAPI.net.beforeRequestMessageName,
vAPI.net.onBeforeRequest
);
});
}; };
/******************************************************************************/ /******************************************************************************/
vAPI.net.unregisterListeners = function() { vAPI.contextMenu = {};
vAPI.messaging.gmm.removeMessageListener(
vAPI.app.cleanName + ':onBeforeRequest', /******************************************************************************/
this.onBeforeRequest
); vAPI.contextMenu.create = function(details, callback) {};
};
/******************************************************************************/
vAPI.contextMenu.remove = function() {};
/******************************************************************************/ /******************************************************************************/
@ -703,30 +894,16 @@ vAPI.lastError = function() {
// clean up when the extension is disabled // clean up when the extension is disabled
window.addEventListener('unload', function() { window.addEventListener('unload', function() {
SQLite.close(); for (var unload of vAPI.unload) {
windowWatcher.unregister(); unload();
vAPI.messaging.unload(); }
vAPI.net.unregisterListeners();
var URI = vAPI.messaging.frameScript.replace('Script.', 'Module.'); // frameModule needs to be cleared too
var frameModule = {}; var frameModule = {};
Cu['import'](URI, frameModule); Cu['import'](vAPI.getURL('frameModule.js'), frameModule);
frameModule.contentPolicy.unregister(); frameModule.contentPolicy.unregister();
frameModule.docObserver.unregister(); frameModule.docObserver.unregister();
Cu.unload(URI); Cu.unload(vAPI.getURL('frameModule.js'));
// close extension tabs
var win, tab, host = vAPI.app.cleanName;
for (win of vAPI.tabs.getWindows()) {
for (tab of win.gBrowser.tabs) {
URI = tab.linkedBrowser.currentURI;
if (URI.scheme === 'chrome' && URI.host === host) {
win.gBrowser.removeTab(tab);
}
}
}
}); });
/******************************************************************************/ /******************************************************************************/

View file

@ -19,6 +19,8 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
/* global addMessageListener, removeMessageListener, sendAsyncMessage */
// For non background pages // For non background pages
/******************************************************************************/ /******************************************************************************/
@ -74,7 +76,7 @@ var messagingConnector = function(response) {
/******************************************************************************/ /******************************************************************************/
var uniqueId = function() { var uniqueId = function() {
return parseInt(Math.random() * 1e10, 10).toString(36); return Math.random().toString(36).slice(2);
}; };
/******************************************************************************/ /******************************************************************************/

View file

@ -69,13 +69,15 @@ vAPI.download = function(details) {
/******************************************************************************/ /******************************************************************************/
vAPI.getURL = function(path) { vAPI.getURL = function(path) {
return 'chrome://ublock/content/' + path.replace(/^\/+/, ''); return 'chrome://' + location.host + '/content/' + path.replace(/^\/+/, '');
}; };
/******************************************************************************/
vAPI.i18n = (function() { vAPI.i18n = (function() {
var stringBundle = Components.classes['@mozilla.org/intl/stringbundle;1'] var stringBundle = Components.classes['@mozilla.org/intl/stringbundle;1']
.getService(Components.interfaces.nsIStringBundleService) .getService(Components.interfaces.nsIStringBundleService)
.createBundle('chrome://ublock/locale/messages.properties'); .createBundle('chrome://' + location.host + '/locale/messages.properties');
return function(s) { return function(s) {
try { try {

View file

@ -37,7 +37,7 @@
<key>Identifier</key> <key>Identifier</key>
<string>toolbarItem</string> <string>toolbarItem</string>
<key>Image</key> <key>Image</key>
<string>img/icon16.png</string> <string>img/browsericons/icon16.png</string>
<key>Label</key> <key>Label</key>
<string>{name}</string> <string>{name}</string>
<key>Popover</key> <key>Popover</key>

View file

@ -74,7 +74,7 @@ var messagingConnector = function(response) {
/******************************************************************************/ /******************************************************************************/
var uniqueId = function() { var uniqueId = function() {
return parseInt(Math.random() * 1e10, 10).toString(36); return Math.random().toString(36).slice(2);
}; };
/******************************************************************************/ /******************************************************************************/
@ -359,7 +359,7 @@ var firstMutation = function() {
'return r;', 'return r;',
'};', '};',
'history.replaceState = function() {', 'history.replaceState = function() {',
'var r = pR.apply(this, arguments);', 'var r = rS.apply(this, arguments);',
'onpopstate();', 'onpopstate();',
'return r;', 'return r;',
'};' '};'

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 603 603">
<g transform="translate(-2.9000336,4.3318037)">
<g transform="matrix(4.4946163,0,0,4.4784113,-1996.8254,-3025.1919)">
<g>
<path d="m 450.58474,716.40132 0,51.00389 35.87406,36.2877 51.05503,0 35.91927,-36.3334 0,-51.68942 -35.03824,-35.44222 -52.20713,0 z" style="fill: #7c7c7c; stroke:#ffffff; stroke-width: 2" />
</g>
</g>
</g>
<g transform="translate(-2.9000336,4.3318037)">
<g transform="matrix(0.97521805,0,0,1.0217146,0,0.07624875)" style="fill:#ffffff">
<path
d="m 218.83305,472.64625 61.97723,0 0,-53.96657 -3.79453,-37.94524 c 3.59241,3.70669 7.58016,6.20123 11.96329,7.48364 4.38293,1.28241 9.10851,1.8797 14.17677,1.79186 9.372,-0.0176 18.03265,-2.61752 25.98195,-7.79986 7.94903,-5.18233 14.60701,-12.84164 19.97396,-22.97795 l 1.68646,0 4.63775,29.09136 50.59366,0 0,-209.12047 -61.97724,0 0,138.28934 c -5.93788,8.16005 -11.7702,14.08021 -17.49698,17.76048 -5.72704,3.68038 -12.40259,5.48981 -20.02665,5.42828 -8.81887,0.21964 -15.31875,-2.64382 -19.49965,-8.59038 -4.18109,-5.94645 -6.25402,-16.29355 -6.21879,-31.04132 l 0,-121.8464 -61.97723,0 z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 401 B

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 603 603">
<g transform="translate(-2.9000336,4.3318037)">
<g transform="matrix(4.4946163,0,0,4.4784113,-1996.8254,-3025.1919)">
<g>
<path d="m 450.58474,716.40132 0,51.00389 35.87406,36.2877 51.05503,0 35.91927,-36.3334 0,-51.68942 -35.03824,-35.44222 -52.20713,0 z" style="fill: #800000; stroke: #ffffff; stroke-width: 2" />
</g>
</g>
</g>
<g transform="translate(-2.9000336,4.3318037)">
<g transform="matrix(0.97521805,0,0,1.0217146,0,0.07624875)" style="fill:#ffffff">
<path
d="m 218.83305,472.64625 61.97723,0 0,-53.96657 -3.79453,-37.94524 c 3.59241,3.70669 7.58016,6.20123 11.96329,7.48364 4.38293,1.28241 9.10851,1.8797 14.17677,1.79186 9.372,-0.0176 18.03265,-2.61752 25.98195,-7.79986 7.94903,-5.18233 14.60701,-12.84164 19.97396,-22.97795 l 1.68646,0 4.63775,29.09136 50.59366,0 0,-209.12047 -61.97724,0 0,138.28934 c -5.93788,8.16005 -11.7702,14.08021 -17.49698,17.76048 -5.72704,3.68038 -12.40259,5.48981 -20.02665,5.42828 -8.81887,0.21964 -15.31875,-2.64382 -19.49965,-8.59038 -4.18109,-5.94645 -6.25402,-16.29355 -6.21879,-31.04132 l 0,-121.8464 -61.97723,0 z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 661 B

After

Width:  |  Height:  |  Size: 661 B

View file

@ -44,14 +44,7 @@ if ( !matches || matches.length !== 2 ) {
return; return;
} }
uDom.onLoad(function() { messager.send({ what : 'getAssetContent', url: matches[1] }, onAssetContentReceived);
messager.send({
what: 'getAssetContent',
url: matches[1]
},
onAssetContentReceived
);
});
/******************************************************************************/ /******************************************************************************/