1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-22 18:32:45 +01:00

remove depending on vapi-appinfo.js

This commit is contained in:
Raymond Hill 2014-12-01 14:25:33 -02:00
parent 012eb98f0e
commit 2e4c0a2bfe
8 changed files with 33 additions and 31 deletions

View File

@ -35,11 +35,19 @@ self.vAPI = self.vAPI || {};
var vAPI = self.vAPI; var vAPI = self.vAPI;
var chrome = self.chrome; var chrome = self.chrome;
var manifest = chrome.runtime.getManifest();
vAPI.chrome = true; vAPI.chrome = true;
/******************************************************************************/ /******************************************************************************/
vAPI.app = {
name: manifest.name,
version: manifest.version
};
/******************************************************************************/
vAPI.storage = chrome.storage.local; vAPI.storage = chrome.storage.local;
/******************************************************************************/ /******************************************************************************/

View File

@ -34,7 +34,6 @@
<script src="js/vapi-common.js"></script> <script src="js/vapi-common.js"></script>
<script src="js/vapi-client.js"></script> <script src="js/vapi-client.js"></script>
<script src="js/vapi-appinfo.js"></script>
<script src="js/udom.js"></script> <script src="js/udom.js"></script>
<script src="js/i18n.js"></script> <script src="js/i18n.js"></script>
<script src="js/dashboard-common.js"></script> <script src="js/dashboard-common.js"></script>

View File

@ -8,7 +8,6 @@
<script src="lib/punycode.min.js"></script> <script src="lib/punycode.min.js"></script>
<script src="lib/publicsuffixlist.min.js"></script> <script src="lib/publicsuffixlist.min.js"></script>
<script src="lib/yamd5.js"></script> <script src="lib/yamd5.js"></script>
<script src="js/vapi-appinfo.js"></script>
<script src="js/vapi-common.js"></script> <script src="js/vapi-common.js"></script>
<script src="js/vapi-background.js"></script> <script src="js/vapi-background.js"></script>
<script src="js/background.js"></script> <script src="js/background.js"></script>

View File

@ -122,11 +122,15 @@ var resetUserData = function() {
/******************************************************************************/ /******************************************************************************/
uDom('#export').on('click', exportToFile); var onAppDataReady = function(appData) {
uDom('#import').on('click', startImportFilePicker); uDom('#aboutNameVer').html(appData.name + ' v' + appData.version);
uDom('#reset').on('click', resetUserData); uDom('#export').on('click', exportToFile);
uDom('#restoreFilePicker').on('change', handleImportFilePicker); uDom('#import').on('click', startImportFilePicker);
uDom('#aboutNameVer').html(vAPI.app.name + ' v' + vAPI.app.version); uDom('#reset').on('click', resetUserData);
uDom('#restoreFilePicker').on('change', handleImportFilePicker);
};
messager.send({ what: 'getAppData' }, onAppDataReady);
/******************************************************************************/ /******************************************************************************/

View File

@ -58,6 +58,10 @@ var onMessage = function(request, sender, callback) {
µb.contextMenuClientY = request.clientY; µb.contextMenuClientY = request.clientY;
break; break;
case 'getAppData':
response = vAPI.app;
break;
case 'getUserSettings': case 'getUserSettings':
response = µb.userSettings; response = µb.userSettings;
break; break;
@ -114,9 +118,11 @@ var getDynamicFilterResults = function(scope) {
var getStats = function(tab) { var getStats = function(tab) {
var r = { var r = {
appName: vAPI.app.name,
appVersion: vAPI.app.version,
globalBlockedRequestCount: µb.localSettings.blockedRequestCount, globalBlockedRequestCount: µb.localSettings.blockedRequestCount,
globalAllowedRequestCount: µb.localSettings.allowedRequestCount, globalAllowedRequestCount: µb.localSettings.allowedRequestCount,
tabId: tab.id, tabId: 0,
pageURL: '', pageURL: '',
pageBlockedRequestCount: 0, pageBlockedRequestCount: 0,
pageAllowedRequestCount: 0, pageAllowedRequestCount: 0,
@ -128,8 +134,9 @@ var getStats = function(tab) {
'/': getDynamicFilterResults('*') '/': getDynamicFilterResults('*')
} }
}; };
var pageStore = µb.pageStoreFromTabId(tab.id); var pageStore = tab && µb.pageStoreFromTabId(tab.id);
if ( pageStore ) { if ( pageStore ) {
r.tabId = tab.id;
r.pageURL = pageStore.pageURL; r.pageURL = pageStore.pageURL;
r.pageHostname = pageStore.pageHostname; r.pageHostname = pageStore.pageHostname;
r.pageBlockedRequestCount = pageStore.perLoadBlockedRequestCount; r.pageBlockedRequestCount = pageStore.perLoadBlockedRequestCount;
@ -146,11 +153,7 @@ var onMessage = function(request, sender, callback) {
// Async // Async
switch ( request.what ) { switch ( request.what ) {
case 'activeTabStats': case 'activeTabStats':
vAPI.tabs.get(null, function(tab) { vAPI.tabs.get(null, function(tab) { callback(getStats(tab)); });
if ( tab ) {
callback(getStats(tab));
}
});
return; return;
default: default:

View File

@ -97,7 +97,7 @@ var syncAllDynamicFilters = function() {
/******************************************************************************/ /******************************************************************************/
var renderStats = function(details) { var renderPopup = function(details) {
if ( details ) { if ( details ) {
stats = details; stats = details;
} }
@ -106,6 +106,10 @@ var renderStats = function(details) {
return; return;
} }
var hdr = uDom('#version');
hdr.nodes[0].previousSibling.textContent = details.appName;
hdr.html(hdr.html() + 'v' + details.appVersion);
var isHTTP = /^https?:\/\/[0-9a-z]/.test(stats.pageURL); var isHTTP = /^https?:\/\/[0-9a-z]/.test(stats.pageURL);
// Conditions for request log: // Conditions for request log:
@ -164,10 +168,6 @@ var renderStats = function(details) {
uDom('#dynamicFilteringToggler').toggleClass('on', stats.dynamicFilteringEnabled); uDom('#dynamicFilteringToggler').toggleClass('on', stats.dynamicFilteringEnabled);
}; };
messager.send( {
what: 'activeTabStats'
}, renderStats );
/******************************************************************************/ /******************************************************************************/
var toggleNetFilteringSwitch = function(ev) { var toggleNetFilteringSwitch = function(ev) {
@ -186,14 +186,6 @@ var toggleNetFilteringSwitch = function(ev) {
/******************************************************************************/ /******************************************************************************/
var renderHeader = function() {
var hdr = uDom('#version');
hdr.nodes[0].previousSibling.textContent = vAPI.app.name;
hdr.html(hdr.html() + 'v' + vAPI.app.version);
};
/******************************************************************************/
var gotoDashboard = function() { var gotoDashboard = function() {
messager.send({ messager.send({
what: 'gotoURL', what: 'gotoURL',
@ -301,8 +293,7 @@ var installEventHandlers = function() {
// Make menu only when popup html is fully loaded // Make menu only when popup html is fully loaded
uDom.onLoad(function() { uDom.onLoad(function() {
renderHeader(); messager.send({ what: 'activeTabStats' }, renderPopup);
renderStats();
installEventHandlers(); installEventHandlers();
}); });

View File

@ -85,7 +85,6 @@
</div> </div>
<script src="js/vapi-common.js"></script> <script src="js/vapi-common.js"></script>
<script src="js/vapi-client.js"></script> <script src="js/vapi-client.js"></script>
<script src="js/vapi-appinfo.js"></script>
<script src="js/udom.js"></script> <script src="js/udom.js"></script>
<script src="js/i18n.js"></script> <script src="js/i18n.js"></script>
<script src="js/popup.js"></script> <script src="js/popup.js"></script>

View File

@ -15,7 +15,6 @@ cp -R src/js $DES/
cp -R src/lib $DES/ cp -R src/lib $DES/
cp -R src/_locales $DES/ cp -R src/_locales $DES/
cp src/*.html $DES/ cp src/*.html $DES/
cp platform/vapi-appinfo.js $DES/js/
cp platform/chromium/*.js $DES/js/ cp platform/chromium/*.js $DES/js/
cp platform/chromium/manifest.json $DES/ cp platform/chromium/manifest.json $DES/
echo "*** uBlock.chromium: Package done." echo "*** uBlock.chromium: Package done."