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

View File

@ -111,10 +111,9 @@ vAPI.tabs = {
// update doesn't accept index, must use move
chrome.tabs.update(details.tabId, _details, function(tab) {
// if the tab doesn't exist
if (chrome.runtime.lastError) {
if ( vAPI.lastError() ) {
chrome.tabs.create(_details);
}
else if (details.index !== undefined) {
} else if ( details.index !== undefined ) {
chrome.tabs.move(tab.id, {index: details.index});
}
});
@ -195,7 +194,7 @@ vAPI.tabs = {
vAPI.setIcon = function(tabId, img, badge) {
var onIconReady = function() {
if ( chrome.runtime.lastError ) {
if ( vAPI.lastError() ) {
return;
}
@ -213,6 +212,7 @@ vAPI.setIcon = function(tabId, img, badge) {
vAPI.messaging = {
ports: {},
listeners: {},
connector: null,
listen: function(listenerName, callback) {
this.listeners[listenerName] = callback;
@ -226,11 +226,11 @@ vAPI.messaging = {
this.connector = function(port) {
var onMessage = function(request) {
var callback = function(response) {
if (chrome.runtime.lastError || response === undefined) {
if ( vAPI.lastError() || response === undefined ) {
return;
}
if (request.requestId) {
if ( request.requestId ) {
port.postMessage({
requestId: request.requestId,
portName: request.portName,
@ -239,16 +239,18 @@ vAPI.messaging = {
}
};
// Default handler
var listener = connector(request.msg, port.sender, callback);
if ( listener !== null ) {
return;
}
if ( listener === null ) {
listener = vAPI.messaging.listeners[request.portName];
if (typeof listener === 'function') {
listener(request.msg, port.sender, callback);
} else {
console.error('µBlock> messaging > unknown request: %o', request);
}
// Specific handler
listener = vAPI.messaging.listeners[request.portName];
if ( typeof listener === 'function' ) {
listener(request.msg, port.sender, callback);
} else {
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
// fetched by one of the occurrences.
if ( entries === null ) {
var lastError = vAPI.lastError;
var lastError = vAPI.lastError();
if ( lastError ) {
console.error(
'µBlock> cachedAssetsManager> getEntries():',
@ -137,7 +137,7 @@ var cachedAssetsManager = (function() {
};
var cachedContentPath = cachedAssetPathPrefix + path;
var onLoaded = function(bin) {
var lastError = vAPI.lastError;
var lastError = vAPI.lastError();
if ( lastError ) {
details.error = 'Error: ' + lastError.message;
console.error('µBlock> cachedAssetsManager.load():', details.error);
@ -169,7 +169,7 @@ var cachedAssetsManager = (function() {
var bin = {};
bin[cachedContentPath] = content;
var onSaved = function() {
var lastError = vAPI.lastError;
var lastError = vAPI.lastError();
if ( lastError ) {
details.error = 'Error: ' + lastError.message;
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,
// as per list headers.
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',
pslPath: 'assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat',

View File

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

View File

@ -594,13 +594,13 @@
var onAllDone = function() {
if (vAPI.chrome) {
// 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.
var scriptDone = function() {
vAPI.lastError;
vAPI.lastError();
};
var scriptEnd = function(tabId) {
if ( vAPI.lastError ) {
if ( vAPI.lastError() ) {
return;
}
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
echo "*** uBlock: Creating web store package"
echo "*** uBlock: Copying files"
cp -R assets dist/ublock/
rm dist/ublock/assets/*.sh
cp -R css dist/ublock/
cp -R img dist/ublock/
cp -R js dist/ublock/
cp -R lib dist/ublock/
cp -R _locales dist/ublock/
cp *.html dist/ublock/
cp *.txt dist/ublock/
cp manifest.json dist/ublock/
echo "*** uBlock: Package done."
echo "*** uBlock.chromium: Creating web store package"
echo "*** uBlock.chromium: Copying files"
DES=dist/uBlock.chromium
mkdir -p $DES
cp -R assets $DES/
rm $DES/assets/*.sh
cp -R src/css $DES/
cp -R src/img $DES/
cp -R src/js $DES/
rm $DES/js/vapi-background.js
rm $DES/js/vapi-client.js
rm $DES/js/vapi-common.js
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."