|
|
|
@ -25,27 +25,37 @@
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the
|
|
|
|
|
// normal way forbid binding behind the scene tab.
|
|
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/67
|
|
|
|
|
// Load everything
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
var µm = µMatrix;
|
|
|
|
|
var tabContext = µm.tabContextManager.mustLookup(vAPI.noTabId);
|
|
|
|
|
µm.pageStores[vAPI.noTabId] = µm.PageStore.factory(tabContext);
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
µMatrix.turnOn();
|
|
|
|
|
var µm = µMatrix;
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// Browser data jobs
|
|
|
|
|
// Important: raise barrier to remote fetching: we do not want resources to
|
|
|
|
|
// be pulled from remote server at start up time.
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
µm.assets.remoteFetchBarrier += 1;
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
var onAllDone = function() {
|
|
|
|
|
µm.webRequest.start();
|
|
|
|
|
|
|
|
|
|
// https://github.com/chrisaljoudi/uBlock/issues/184
|
|
|
|
|
// Check for updates not too far in the future.
|
|
|
|
|
µm.assetUpdater.onStart.addListener(µm.updateStartHandler.bind(µm));
|
|
|
|
|
µm.assetUpdater.onCompleted.addListener(µm.updateCompleteHandler.bind(µm));
|
|
|
|
|
µm.assetUpdater.onAssetUpdated.addListener(µm.assetUpdatedHandler.bind(µm));
|
|
|
|
|
µm.assets.onAssetCacheRemoved.addListener(µm.assetCacheRemovedHandler.bind(µm));
|
|
|
|
|
|
|
|
|
|
// Browser data jobs
|
|
|
|
|
var jobCallback = function() {
|
|
|
|
|
var µm = µMatrix;
|
|
|
|
|
if ( !µm.userSettings.clearBrowserCache ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -60,65 +70,54 @@
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
µMatrix.asyncJobs.add('clearBrowserCache', null, jobCallback, 15 * 60 * 1000, true);
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// Automatic update of non-user assets
|
|
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/334
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
var µm = µMatrix;
|
|
|
|
|
|
|
|
|
|
// https://github.com/chrisaljoudi/uBlock/issues/184
|
|
|
|
|
// Check for updates not too far in the future.
|
|
|
|
|
µm.assetUpdater.onStart.addListener(µm.updateStartHandler.bind(µm));
|
|
|
|
|
µm.assetUpdater.onCompleted.addListener(µm.updateCompleteHandler.bind(µm));
|
|
|
|
|
µm.assetUpdater.onAssetUpdated.addListener(µm.assetUpdatedHandler.bind(µm));
|
|
|
|
|
µm.assets.onAssetCacheRemoved.addListener(µm.assetCacheRemovedHandler.bind(µm));
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// Load everything
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
var µm = µMatrix;
|
|
|
|
|
|
|
|
|
|
µm.assets.remoteFetchBarrier += 1;
|
|
|
|
|
// Important: remove barrier to remote fetching, this was useful only
|
|
|
|
|
// for launch time.
|
|
|
|
|
µm.assets.remoteFetchBarrier -= 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// This needs to be done when the PSL is loaded
|
|
|
|
|
var bindTabs = function(tabs) {
|
|
|
|
|
var onTabsReady = function(tabs) {
|
|
|
|
|
var tab;
|
|
|
|
|
var i = tabs.length;
|
|
|
|
|
// console.debug('start.js > binding %d tabs', i);
|
|
|
|
|
while ( i-- ) {
|
|
|
|
|
tab = tabs[i];
|
|
|
|
|
µm.tabContextManager.commit(tab.id, tab.url);
|
|
|
|
|
// https://github.com/gorhill/uMatrix/issues/56
|
|
|
|
|
// We must unbind first to flush out potentially bad domain names.
|
|
|
|
|
µm.unbindTabFromPageStats(tab.id);
|
|
|
|
|
µm.bindTabToPageStats(tab.id);
|
|
|
|
|
}
|
|
|
|
|
µm.webRequest.start();
|
|
|
|
|
|
|
|
|
|
// Important: remove barrier to remote fetching, this was useful only
|
|
|
|
|
// for launch time.
|
|
|
|
|
µm.assets.remoteFetchBarrier -= 1;
|
|
|
|
|
};
|
|
|
|
|
onAllDone();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var queryTabs = function() {
|
|
|
|
|
vAPI.tabs.getAll(bindTabs);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var onSettingsReady = function(settings) {
|
|
|
|
|
µm.loadPublicSuffixList(queryTabs);
|
|
|
|
|
var onSettingsReady = function(settings) {
|
|
|
|
|
µm.loadHostsFiles();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var onMatrixReady = function() {
|
|
|
|
|
};
|
|
|
|
|
var onMatrixReady = function() {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var onPSLReady = function() {
|
|
|
|
|
µm.loadUserSettings(onSettingsReady);
|
|
|
|
|
µm.loadMatrix(onMatrixReady);
|
|
|
|
|
|
|
|
|
|
// rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the
|
|
|
|
|
// normal way forbid binding behind the scene tab.
|
|
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/67
|
|
|
|
|
µm.pageStores[vAPI.noTabId] = µm.PageStore.factory(
|
|
|
|
|
µm.tabContextManager.mustLookup(vAPI.noTabId)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
vAPI.tabs.getAll(onTabsReady);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Must be done ASAP
|
|
|
|
|
µm.loadPublicSuffixList(onPSLReady);
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|