diff --git a/meta/crx/manifest.json b/meta/crx/manifest.json index 0f5d2262e..321cc96be 100644 --- a/meta/crx/manifest.json +++ b/meta/crx/manifest.json @@ -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://*/*" + ] } \ No newline at end of file diff --git a/meta/crx/vapi-background.js b/meta/crx/vapi-background.js index 6af3cb7db..d5a0eda0c 100644 --- a/meta/crx/vapi-background.js +++ b/meta/crx/vapi-background.js @@ -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); } }; diff --git a/src/js/assets.js b/src/js/assets.js index 8f0826803..1243b9c71 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -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); diff --git a/src/js/background.js b/src/js/background.js index d0ffe6fa2..0f3340567 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -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', diff --git a/src/js/messaging.js b/src/js/messaging.js index ee3890fae..246623bc0 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -20,6 +20,7 @@ */ /* global µBlock, YaMD5 */ + 'use strict'; /******************************************************************************/ diff --git a/src/js/storage.js b/src/js/storage.js index 698a7e1d5..85f67a1f2 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -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, { diff --git a/tools/make-chrome.sh b/tools/make-chrome.sh old mode 100644 new mode 100755 index 44ba95794..3dae2e36d --- a/tools/make-chrome.sh +++ b/tools/make-chrome.sh @@ -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."