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 chrome = self.chrome;
var manifest = chrome.runtime.getManifest();
vAPI.chrome = true;
/******************************************************************************/
vAPI.app = {
name: manifest.name,
version: manifest.version
};
/******************************************************************************/
vAPI.storage = chrome.storage.local;
/******************************************************************************/

View File

@ -34,7 +34,6 @@
<script src="js/vapi-common.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/i18n.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/publicsuffixlist.min.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-background.js"></script>
<script src="js/background.js"></script>

View File

@ -122,11 +122,15 @@ var resetUserData = function() {
/******************************************************************************/
uDom('#export').on('click', exportToFile);
uDom('#import').on('click', startImportFilePicker);
uDom('#reset').on('click', resetUserData);
uDom('#restoreFilePicker').on('change', handleImportFilePicker);
uDom('#aboutNameVer').html(vAPI.app.name + ' v' + vAPI.app.version);
var onAppDataReady = function(appData) {
uDom('#aboutNameVer').html(appData.name + ' v' + appData.version);
uDom('#export').on('click', exportToFile);
uDom('#import').on('click', startImportFilePicker);
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;
break;
case 'getAppData':
response = vAPI.app;
break;
case 'getUserSettings':
response = µb.userSettings;
break;
@ -114,9 +118,11 @@ var getDynamicFilterResults = function(scope) {
var getStats = function(tab) {
var r = {
appName: vAPI.app.name,
appVersion: vAPI.app.version,
globalBlockedRequestCount: µb.localSettings.blockedRequestCount,
globalAllowedRequestCount: µb.localSettings.allowedRequestCount,
tabId: tab.id,
tabId: 0,
pageURL: '',
pageBlockedRequestCount: 0,
pageAllowedRequestCount: 0,
@ -128,8 +134,9 @@ var getStats = function(tab) {
'/': getDynamicFilterResults('*')
}
};
var pageStore = µb.pageStoreFromTabId(tab.id);
var pageStore = tab && µb.pageStoreFromTabId(tab.id);
if ( pageStore ) {
r.tabId = tab.id;
r.pageURL = pageStore.pageURL;
r.pageHostname = pageStore.pageHostname;
r.pageBlockedRequestCount = pageStore.perLoadBlockedRequestCount;
@ -146,11 +153,7 @@ var onMessage = function(request, sender, callback) {
// Async
switch ( request.what ) {
case 'activeTabStats':
vAPI.tabs.get(null, function(tab) {
if ( tab ) {
callback(getStats(tab));
}
});
vAPI.tabs.get(null, function(tab) { callback(getStats(tab)); });
return;
default:

View File

@ -97,7 +97,7 @@ var syncAllDynamicFilters = function() {
/******************************************************************************/
var renderStats = function(details) {
var renderPopup = function(details) {
if ( details ) {
stats = details;
}
@ -106,6 +106,10 @@ var renderStats = function(details) {
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);
// Conditions for request log:
@ -164,10 +168,6 @@ var renderStats = function(details) {
uDom('#dynamicFilteringToggler').toggleClass('on', stats.dynamicFilteringEnabled);
};
messager.send( {
what: 'activeTabStats'
}, renderStats );
/******************************************************************************/
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() {
messager.send({
what: 'gotoURL',
@ -301,8 +293,7 @@ var installEventHandlers = function() {
// Make menu only when popup html is fully loaded
uDom.onLoad(function() {
renderHeader();
renderStats();
messager.send({ what: 'activeTabStats' }, renderPopup);
installEventHandlers();
});

View File

@ -85,7 +85,6 @@
</div>
<script src="js/vapi-common.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/i18n.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/_locales $DES/
cp src/*.html $DES/
cp platform/vapi-appinfo.js $DES/js/
cp platform/chromium/*.js $DES/js/
cp platform/chromium/manifest.json $DES/
echo "*** uBlock.chromium: Package done."