mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Add license headers, plus some code styling
This commit is contained in:
parent
8bb0d3276b
commit
ecdee65fda
13 changed files with 156 additions and 23 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
41
platform/firefox/bootstrap.js
vendored
41
platform/firefox/bootstrap.js
vendored
|
|
@ -1,12 +1,37 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
µ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
|
||||||
|
*/
|
||||||
|
|
||||||
/* global Services, APP_STARTUP, APP_SHUTDOWN */
|
/* global Services, APP_STARTUP, APP_SHUTDOWN */
|
||||||
/* exported startup, shutdown, install, uninstall */
|
/* exported startup, shutdown, install, uninstall */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
Components.utils['import']('resource://gre/modules/Services.jsm');
|
/******************************************************************************/
|
||||||
|
|
||||||
var bgProcess;
|
var bgProcess;
|
||||||
|
|
||||||
|
Components.utils['import']('resource://gre/modules/Services.jsm');
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
function startup(data, reason) {
|
function startup(data, reason) {
|
||||||
bgProcess = function(ev) {
|
bgProcess = function(ev) {
|
||||||
if (ev) {
|
if (ev) {
|
||||||
|
|
@ -33,13 +58,23 @@ function startup(data, reason) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
function shutdown(data, reason) {
|
function shutdown(data, reason) {
|
||||||
if (reason !== APP_SHUTDOWN) {
|
if (reason !== APP_SHUTDOWN) {
|
||||||
bgProcess.parentNode.removeChild(bgProcess);
|
bgProcess.parentNode.removeChild(bgProcess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://bugzil.la/719376
|
/******************************************************************************/
|
||||||
function install() Services.strings.flushBundles();
|
|
||||||
|
function install() {
|
||||||
|
// https://bugzil.la/719376
|
||||||
|
Services.strings.flushBundles();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
function uninstall() {}
|
function uninstall() {}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,46 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
µ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
|
||||||
|
*/
|
||||||
|
|
||||||
/* global Services, Components, XPCOMUtils */
|
/* global Services, Components, XPCOMUtils */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
this.EXPORTED_SYMBOLS = ['contentPolicy', 'docObserver'];
|
this.EXPORTED_SYMBOLS = ['contentPolicy', 'docObserver'];
|
||||||
|
|
||||||
Components.utils['import']('resource://gre/modules/Services.jsm');
|
const {interfaces: Ci, utils: Cu} = Components;
|
||||||
Components.utils['import']('resource://gre/modules/XPCOMUtils.jsm');
|
|
||||||
// Components.utils['import']('resource://gre/modules/devtools/Console.jsm');
|
|
||||||
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
let appName;
|
let appName;
|
||||||
|
|
||||||
try { throw new Error; } catch (ex) {
|
try { throw new Error; } catch (ex) {
|
||||||
appName = ex.fileName.match(/:\/\/([^\/]+)/)[1];
|
appName = ex.fileName.match(/:\/\/([^\/]+)/)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cu['import']('resource://gre/modules/Services.jsm');
|
||||||
|
Cu['import']('resource://gre/modules/XPCOMUtils.jsm');
|
||||||
|
// Cu['import']('resource://gre/modules/devtools/Console.jsm');
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
let getMessager = function(win) {
|
let getMessager = function(win) {
|
||||||
try {
|
try {
|
||||||
// e10s
|
// e10s
|
||||||
|
|
@ -35,6 +61,8 @@ let getMessager = function(win) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
let contentPolicy = {
|
let contentPolicy = {
|
||||||
classDescription: 'content-policy implementation for ' + appName,
|
classDescription: 'content-policy implementation for ' + appName,
|
||||||
classID: Components.ID('{e6d173c8-8dbf-4189-a6fd-189e8acffd27}'),
|
classID: Components.ID('{e6d173c8-8dbf-4189-a6fd-189e8acffd27}'),
|
||||||
|
|
@ -100,7 +128,7 @@ let contentPolicy = {
|
||||||
let result = getMessager(win).sendSyncMessage(this.requestMessageName, {
|
let result = getMessager(win).sendSyncMessage(this.requestMessageName, {
|
||||||
url: location.spec,
|
url: location.spec,
|
||||||
type: type,
|
type: type,
|
||||||
tabId: -1,
|
tabId: -1, // determined in background script
|
||||||
frameId: type === 6 ? -1 : (win === win.top ? 0 : 1),
|
frameId: type === 6 ? -1 : (win === win.top ? 0 : 1),
|
||||||
parentFrameId: win === win.top ? -1 : 0
|
parentFrameId: win === win.top ? -1 : 0
|
||||||
})[0];
|
})[0];
|
||||||
|
|
@ -112,13 +140,15 @@ let contentPolicy = {
|
||||||
}*/
|
}*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
let docObserver = {
|
let docObserver = {
|
||||||
contentBaseURI: 'chrome://' + appName + '/content/',
|
contentBaseURI: 'chrome://' + appName + '/content/',
|
||||||
initContext: function(win, sandbox) {
|
initContext: function(win, sandbox) {
|
||||||
let messager = getMessager(win);
|
let messager = getMessager(win);
|
||||||
|
|
||||||
if (sandbox) {
|
if (sandbox) {
|
||||||
win = Components.utils.Sandbox([win], {
|
win = Cu.Sandbox([win], {
|
||||||
sandboxPrototype: win,
|
sandboxPrototype: win,
|
||||||
wantComponents: false,
|
wantComponents: false,
|
||||||
wantXHRConstructor: false
|
wantXHRConstructor: false
|
||||||
|
|
@ -127,10 +157,10 @@ let docObserver = {
|
||||||
win.self = win;
|
win.self = win;
|
||||||
|
|
||||||
// anonymous function needs to be used here
|
// anonymous function needs to be used here
|
||||||
win.injectScript = Components.utils.exportFunction(
|
win.injectScript = Cu.exportFunction(
|
||||||
function(script, evalCode) {
|
function(script, evalCode) {
|
||||||
if (evalCode) {
|
if (evalCode) {
|
||||||
Components.utils.evalInSandbox(script, win);
|
Cu.evalInSandbox(script, win);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,5 +216,9 @@ let docObserver = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
contentPolicy.register();
|
contentPolicy.register();
|
||||||
docObserver.register();
|
docObserver.register();
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,36 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
µ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
|
||||||
|
*/
|
||||||
|
|
||||||
/* globals Services, sendAsyncMessage, addMessageListener, removeMessageListener */
|
/* globals Services, sendAsyncMessage, addMessageListener, removeMessageListener */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
(function(frameScriptContext) {
|
(function(frameScriptContext) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
let appName;
|
let appName;
|
||||||
let listeners = {};
|
let listeners = {};
|
||||||
|
|
||||||
|
|
@ -13,6 +40,8 @@ try { throw new Error; } catch (ex) {
|
||||||
|
|
||||||
Components.utils['import']('chrome://' + appName + '/content/frameModule.js', {});
|
Components.utils['import']('chrome://' + appName + '/content/frameModule.js', {});
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
frameScriptContext[appName + '_addMessageListener'] = function(id, fn) {
|
frameScriptContext[appName + '_addMessageListener'] = function(id, fn) {
|
||||||
frameScriptContext[appName + '_removeMessageListener'](id);
|
frameScriptContext[appName + '_removeMessageListener'](id);
|
||||||
listeners[id] = function(msg) {
|
listeners[id] = function(msg) {
|
||||||
|
|
@ -29,10 +58,16 @@ frameScriptContext[appName + '_removeMessageListener'] = function(id) {
|
||||||
delete listeners[id];
|
delete listeners[id];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
addMessageListener(appName + ':broadcast', function(msg) {
|
addMessageListener(appName + ':broadcast', function(msg) {
|
||||||
for (let id in listeners) {
|
for (let id in listeners) {
|
||||||
listeners[id](msg);
|
listeners[id](msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
})(this);
|
/******************************************************************************/
|
||||||
|
|
||||||
|
})(this);
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
@ -56,6 +56,7 @@ vAPI.app.restart = function() {};
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// list of things that needs to be destroyed when disabling the extension
|
// list of things that needs to be destroyed when disabling the extension
|
||||||
|
// only functions should be added to it
|
||||||
|
|
||||||
vAPI.unload = [];
|
vAPI.unload = [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,33 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
µ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
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
// Adding new URL requires to whitelist it in the background script too (addContentScriptFromURL)
|
// Adding new URL requires to whitelist it in the background script too (addContentScriptFromURL)
|
||||||
// Note that the sitePach function will be converted to a string, and injected
|
// Note that the sitePach function will be converted to a string, and injected
|
||||||
// into the web-page in order to run in that scope. Because of this, variables
|
// into the web-page in order to run in that scope. Because of this, variables
|
||||||
// from the extension scope won't be accessible in the sitePatch function.
|
// from the extension scope won't be accessible in the sitePatch function.
|
||||||
'use strict';
|
|
||||||
|
|
||||||
self.vAPI = self.vAPI || {};
|
self.vAPI = self.vAPI || {};
|
||||||
|
|
||||||
|
|
@ -33,8 +58,10 @@ if (/^www\.youtube(-nocookie)?\.com/.test(location.host)) {
|
||||||
playerConfig = data;
|
playerConfig = data;
|
||||||
|
|
||||||
var playerRoot = document.querySelector('[data-swf-config]');
|
var playerRoot = document.querySelector('[data-swf-config]');
|
||||||
if (playerRoot)
|
|
||||||
|
if (playerRoot) {
|
||||||
playerRoot.dataset.swfConfig = JSON.stringify(yt.playerConfig);
|
playerRoot.dataset.swfConfig = JSON.stringify(yt.playerConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'config_': {
|
'config_': {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global µBlock, SafariBrowserTab */
|
/* global µBlock, SafariBrowserTab */
|
||||||
|
|
||||||
// For background page
|
// For background page
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a Chromium browser extension to block requests.
|
µBlock - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014 The µBlock authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue