continued: corralling platform-specific stuff into their meta folder

This commit is contained in:
Raymond Hill 2014-11-16 00:21:13 -02:00
parent eafc96859c
commit 84c069dfaa
7 changed files with 68 additions and 67 deletions

View file

@ -1,40 +1,29 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"minimum_chrome_version": "22.0",
"default_locale": "{def_lang}",
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "{version}", "name": "µBlock",
"name": "{name}", "version": "0.7.0.10",
"default_locale": "en",
"description": "__MSG_extShortDesc__", "description": "__MSG_extShortDesc__",
"homepage_url": "{url}",
"author": "{author}",
"developer": {
"name": "{author}",
"email": "{author_email}"
},
"icons": { "icons": {
"16": "img/icon_16.png", "16": "img/icon_16.png",
"128": "img/icon_128.png" "128": "img/icon_128.png"
}, },
"permissions": [ "browser_action": {
"contextMenus", "default_icon": {
"storage", "19": "img/browsericons/icon19-off.png",
"tabs", "38": "img/browsericons/icon38-off.png"
"unlimitedStorage", },
"webNavigation", "default_title": "µBlock",
"webRequest", "default_popup": "popup.html"
"webRequestBlocking", },
"http://*/*",
"https://*/*"
],
"author": "Raymond Hill",
"background": { "background": {
"page": "background.html" "page": "background.html"
}, },
"options_page": "dashboard.html",
"content_scripts": [ "content_scripts": [
{ {
"matches": ["http://*/*", "https://*/*"], "matches": ["http://*/*", "https://*/*"],
@ -49,13 +38,17 @@
"all_frames": true "all_frames": true
} }
], ],
"minimum_chrome_version": "22.0",
"browser_action": { "options_page": "dashboard.html",
"default_icon": { "permissions": [
"19": "img/browsericons/icon19-off.png", "contextMenus",
"38": "img/browsericons/icon38-off.png" "storage",
}, "tabs",
"default_title": "{name}", "unlimitedStorage",
"default_popup": "popup.html" "webNavigation",
} "webRequest",
"webRequestBlocking",
"http://*/*",
"https://*/*"
]
} }

View file

@ -111,10 +111,9 @@ vAPI.tabs = {
// update doesn't accept index, must use move // update doesn't accept index, must use move
chrome.tabs.update(details.tabId, _details, function(tab) { chrome.tabs.update(details.tabId, _details, function(tab) {
// if the tab doesn't exist // if the tab doesn't exist
if (chrome.runtime.lastError) { if ( vAPI.lastError() ) {
chrome.tabs.create(_details); chrome.tabs.create(_details);
} } else if ( details.index !== undefined ) {
else if (details.index !== undefined) {
chrome.tabs.move(tab.id, {index: details.index}); chrome.tabs.move(tab.id, {index: details.index});
} }
}); });
@ -195,7 +194,7 @@ vAPI.tabs = {
vAPI.setIcon = function(tabId, img, badge) { vAPI.setIcon = function(tabId, img, badge) {
var onIconReady = function() { var onIconReady = function() {
if ( chrome.runtime.lastError ) { if ( vAPI.lastError() ) {
return; return;
} }
@ -213,6 +212,7 @@ vAPI.setIcon = function(tabId, img, badge) {
vAPI.messaging = { vAPI.messaging = {
ports: {}, ports: {},
listeners: {}, listeners: {},
connector: null,
listen: function(listenerName, callback) { listen: function(listenerName, callback) {
this.listeners[listenerName] = callback; this.listeners[listenerName] = callback;
@ -226,11 +226,11 @@ vAPI.messaging = {
this.connector = function(port) { this.connector = function(port) {
var onMessage = function(request) { var onMessage = function(request) {
var callback = function(response) { var callback = function(response) {
if (chrome.runtime.lastError || response === undefined) { if ( vAPI.lastError() || response === undefined ) {
return; return;
} }
if (request.requestId) { if ( request.requestId ) {
port.postMessage({ port.postMessage({
requestId: request.requestId, requestId: request.requestId,
portName: request.portName, portName: request.portName,
@ -239,16 +239,18 @@ vAPI.messaging = {
} }
}; };
// Default handler
var listener = connector(request.msg, port.sender, callback); var listener = connector(request.msg, port.sender, callback);
if ( listener !== null ) {
return;
}
if ( listener === null ) { // Specific handler
listener = vAPI.messaging.listeners[request.portName]; listener = vAPI.messaging.listeners[request.portName];
if ( typeof listener === 'function' ) {
if (typeof listener === 'function') { listener(request.msg, port.sender, callback);
listener(request.msg, port.sender, callback); } else {
} else { console.error('µBlock> messaging > unknown request: %o', request);
console.error('µBlock> messaging > unknown request: %o', request);
}
} }
}; };

View file

@ -113,7 +113,7 @@ var cachedAssetsManager = (function() {
// Maybe the index was requested multiple times and already // Maybe the index was requested multiple times and already
// fetched by one of the occurrences. // fetched by one of the occurrences.
if ( entries === null ) { if ( entries === null ) {
var lastError = vAPI.lastError; var lastError = vAPI.lastError();
if ( lastError ) { if ( lastError ) {
console.error( console.error(
'µBlock> cachedAssetsManager> getEntries():', 'µBlock> cachedAssetsManager> getEntries():',
@ -137,7 +137,7 @@ var cachedAssetsManager = (function() {
}; };
var cachedContentPath = cachedAssetPathPrefix + path; var cachedContentPath = cachedAssetPathPrefix + path;
var onLoaded = function(bin) { var onLoaded = function(bin) {
var lastError = vAPI.lastError; var lastError = vAPI.lastError();
if ( lastError ) { if ( lastError ) {
details.error = 'Error: ' + lastError.message; details.error = 'Error: ' + lastError.message;
console.error('µBlock> cachedAssetsManager.load():', details.error); console.error('µBlock> cachedAssetsManager.load():', details.error);
@ -169,7 +169,7 @@ var cachedAssetsManager = (function() {
var bin = {}; var bin = {};
bin[cachedContentPath] = content; bin[cachedContentPath] = content;
var onSaved = function() { var onSaved = function() {
var lastError = vAPI.lastError; var lastError = vAPI.lastError();
if ( lastError ) { if ( lastError ) {
details.error = 'Error: ' + lastError.message; details.error = 'Error: ' + lastError.message;
console.error('µBlock> cachedAssetsManager.save():', details.error); console.error('µBlock> cachedAssetsManager.save():', details.error);

View file

@ -78,7 +78,7 @@ return {
// EasyList, EasyPrivacy and many others have an 4-day update period, // EasyList, EasyPrivacy and many others have an 4-day update period,
// as per list headers. // as per list headers.
updateAssetsEvery: 75 * oneHour + 23 * oneMinute + 53 * oneSecond + 605, updateAssetsEvery: 75 * oneHour + 23 * oneMinute + 53 * oneSecond + 605,
projectServerRoot: 'https://raw.githubusercontent.com/gorhill/uBlock/master/src', projectServerRoot: 'https://raw.githubusercontent.com/gorhill/uBlock/master/',
userFiltersPath: 'assets/user/filters.txt', userFiltersPath: 'assets/user/filters.txt',
pslPath: 'assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat', pslPath: 'assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat',

View file

@ -20,6 +20,7 @@
*/ */
/* global µBlock, YaMD5 */ /* global µBlock, YaMD5 */
'use strict'; 'use strict';
/******************************************************************************/ /******************************************************************************/

View file

@ -594,13 +594,13 @@
var onAllDone = function() { var onAllDone = function() {
if (vAPI.chrome) { if (vAPI.chrome) {
// http://code.google.com/p/chromium/issues/detail?id=410868#c11 // http://code.google.com/p/chromium/issues/detail?id=410868#c11
// Need to be sure to access `vAPI.lastError` to prevent // Need to be sure to access `vAPI.lastError()` to prevent
// spurious warnings in the console. // spurious warnings in the console.
var scriptDone = function() { var scriptDone = function() {
vAPI.lastError; vAPI.lastError();
}; };
var scriptEnd = function(tabId) { var scriptEnd = function(tabId) {
if ( vAPI.lastError ) { if ( vAPI.lastError() ) {
return; return;
} }
vAPI.tabs.injectScript(tabId, { vAPI.tabs.injectScript(tabId, {

31
tools/make-chrome.sh Normal file → Executable file
View file

@ -2,16 +2,21 @@
# #
# This script assumes a linux environment # This script assumes a linux environment
echo "*** uBlock: Creating web store package" echo "*** uBlock.chromium: Creating web store package"
echo "*** uBlock: Copying files" echo "*** uBlock.chromium: Copying files"
cp -R assets dist/ublock/ DES=dist/uBlock.chromium
rm dist/ublock/assets/*.sh mkdir -p $DES
cp -R css dist/ublock/ cp -R assets $DES/
cp -R img dist/ublock/ rm $DES/assets/*.sh
cp -R js dist/ublock/ cp -R src/css $DES/
cp -R lib dist/ublock/ cp -R src/img $DES/
cp -R _locales dist/ublock/ cp -R src/js $DES/
cp *.html dist/ublock/ rm $DES/js/vapi-background.js
cp *.txt dist/ublock/ rm $DES/js/vapi-client.js
cp manifest.json dist/ublock/ rm $DES/js/vapi-common.js
echo "*** uBlock: Package done." cp -R src/lib $DES/
cp -R src/_locales $DES/
cp src/*.html $DES/
cp meta/crx/*.js $DES/js/
cp meta/crx/manifest.json $DES/
echo "*** uBlock.chromium: Package done."