work around some firefox specific issues
This commit is contained in:
parent
b8d2eaeca0
commit
bff8a80c19
8 changed files with 70 additions and 27 deletions
|
@ -33,6 +33,7 @@
|
|||
|
||||
if (rootObject.runtime.lastError) {
|
||||
rootObject.browserAction.disable(tabId);
|
||||
rootObject.browserAction.setBadgeText({text: "-"});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,7 +41,7 @@
|
|||
|
||||
const numFrames = allHosts
|
||||
? Array.from(new Set(allHosts)).length.toString()
|
||||
: "";
|
||||
: "-";
|
||||
|
||||
rootObject.browserAction.setBadgeText({
|
||||
text: numFrames,
|
||||
|
@ -50,12 +51,23 @@
|
|||
);
|
||||
};
|
||||
|
||||
rootObject.windows.onFocusChanged.addListener(updateBrowserActionBadge);
|
||||
rootObject.tabs.onUpdated.addListener(updateBrowserActionBadge);
|
||||
rootObject.tabs.onActivated.addListener(updateBrowserActionBadge);
|
||||
rootObject.windows.onFocusChanged.addListener(updateBrowserActionBadge);
|
||||
|
||||
window.setInterval(function () {
|
||||
rootObject.tabs.getCurrent(function (currentTab) {
|
||||
if (currentTab === undefined) {
|
||||
return;
|
||||
}
|
||||
updateBrowserActionBadge({tabId: currentTab.id});
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
// Listen for updates to the domain rules from the config page.
|
||||
rootObject.runtime.onMessage.addListener(function (request, ignore, sendResponse) {
|
||||
|
||||
const [label, data] = request;
|
||||
if (label === "rulesUpdate") {
|
||||
domainRules = data;
|
||||
|
|
|
@ -23,6 +23,13 @@
|
|||
<button @click="onAggressiveClicked">
|
||||
Use Aggressive Settings
|
||||
</button>
|
||||
<button @click="onClearClicked">
|
||||
Clear Settings
|
||||
</button>
|
||||
<button @click="onAllClicked">
|
||||
Block All
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -54,6 +61,14 @@
|
|||
},
|
||||
onAggressiveClicked: function () {
|
||||
this.$root.$data.setSelectedStandards(standardsDefaults.aggressive);
|
||||
},
|
||||
onClearClicked: function () {
|
||||
this.$root.$data.setSelectedStandards([]);
|
||||
},
|
||||
onAllClicked: function () {
|
||||
const allStandards = Object.keys(this.standards)
|
||||
.map(aStdName => this.standards[aStdName].info.idenitifer);
|
||||
this.$root.$data.setSelectedStandards(allStandards);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
(function () {
|
||||
"use strict";
|
||||
|
||||
window.WEB_API_MANAGER.stateLib = {};
|
||||
const defaultDomain = "(default)";
|
||||
|
||||
window.WEB_API_MANAGER.stateLib.generateStateObject = function (initialDomain, standards) {
|
||||
const generateStateObject = function (initialDomain, standards) {
|
||||
|
||||
const state = {
|
||||
selectedDomain: initialDomain,
|
||||
|
@ -31,14 +31,15 @@
|
|||
},
|
||||
|
||||
deleteDomainRule: function (domainToDelete) {
|
||||
delete this.domainRules[domainToDelete];
|
||||
this.domainNames = Object.keys(this.domainRules);
|
||||
|
||||
// If we're deleted the domain thats currently selected, then
|
||||
// select the default domain.
|
||||
if (this.selectedDomain === domainToDelete) {
|
||||
this.setSelectedDomain(this.defaultDomain);
|
||||
this.setSelectedDomain(defaultDomain);
|
||||
}
|
||||
|
||||
delete this.domainRules[domainToDelete];
|
||||
this.domainNames = Object.keys(this.domainRules);
|
||||
},
|
||||
|
||||
addDomainRule: function (newDomainRule) {
|
||||
|
@ -50,4 +51,8 @@
|
|||
|
||||
return state;
|
||||
};
|
||||
|
||||
window.WEB_API_MANAGER.stateLib = {
|
||||
generateStateObject
|
||||
};
|
||||
}());
|
|
@ -19,7 +19,7 @@
|
|||
window.WEB_API_MANAGER_PAGE = {
|
||||
standards: ${JSON.stringify(standards)},
|
||||
toBlock: ${JSON.stringify(standardsToBlock)},
|
||||
shouldLog: true
|
||||
shouldLog: false
|
||||
};
|
||||
###-INJECTED-PROXY-BLOCKING-CODE-###
|
||||
`;
|
||||
|
|
|
@ -127,13 +127,18 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if (shouldLog === true) {
|
||||
parentRef[lastPropertyName] = createBlockingProxy(keyPath);
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
if (shouldLog === true) {
|
||||
parentRef[lastPropertyName] = createBlockingProxy(keyPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
parentRef[lastPropertyName] = defaultBlockingProxy;
|
||||
return true;
|
||||
parentRef[lastPropertyName] = defaultBlockingProxy;
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.log("Error instrumenting " + keyPath + ": " + e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
featuresToBlock.forEach(blockFeatureAtKeyPath);
|
||||
|
|
|
@ -3,18 +3,17 @@
|
|||
(function () {
|
||||
"use strict";
|
||||
|
||||
const {btoa, atob} = window;
|
||||
const bucketSize = 8;
|
||||
|
||||
const bufferToBase64 = function (buf) {
|
||||
const binstr = Array.prototype.map.call(buf, function (ch) {
|
||||
return String.fromCharCode(ch);
|
||||
}).join('');
|
||||
return btoa(binstr);
|
||||
return window.btoa(binstr);
|
||||
};
|
||||
|
||||
const base64ToBuffer = function (base64) {
|
||||
const binstr = atob(base64);
|
||||
const base64StrToBuffer = function (base64str) {
|
||||
const binstr = window.atob(base64str);
|
||||
const buf = new Uint8Array(binstr.length);
|
||||
Array.prototype.forEach.call(binstr, function (ch, i) {
|
||||
buf[i] = ch.charCodeAt(0);
|
||||
|
@ -75,7 +74,7 @@
|
|||
options.sort();
|
||||
|
||||
const binnedOptions = options.reduce(binToBucketSizeFunc, []);
|
||||
const bitFields = base64ToBuffer(data);
|
||||
const bitFields = base64StrToBuffer(data);
|
||||
|
||||
const result = [];
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
"use strict";
|
||||
|
||||
const rootObject = window.browser || window.chrome;
|
||||
const defaultConservativeRules = window.WEB_API_MANAGER.defaults.conservative;
|
||||
const webApiManagerKeySettingsKey = "webApiManagerDomainRules";
|
||||
const storageObject = rootObject.storage;
|
||||
|
||||
|
@ -14,10 +13,10 @@
|
|||
let loadedDomainRules = results && results[webApiManagerKeySettingsKey];
|
||||
|
||||
// If there are no currently saved domain rules, then create
|
||||
// a stubbed out one, using the conservative blocking rule set.
|
||||
// a stubbed out one, using an empty blocking rule set.
|
||||
if (!loadedDomainRules || Object.keys(loadedDomainRules).length === 0) {
|
||||
loadedDomainRules = {
|
||||
"(default)": defaultConservativeRules
|
||||
"(default)": []
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,30 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "WebAPI Manager",
|
||||
"version": "0.7",
|
||||
"version": "0.8",
|
||||
"description": "Improves browser security by restricting page access to parts of the Web API.",
|
||||
"icons": {
|
||||
"48": "images/uic-48.png",
|
||||
"128": "images/uic-128.png"
|
||||
},
|
||||
"browser_action": {
|
||||
"default_popup": "popup/popup.html"
|
||||
"default_popup": "popup/popup.html",
|
||||
"default_icon": {
|
||||
"48": "images/uic-48.png",
|
||||
"128": "images/uic-128.png"
|
||||
}
|
||||
},
|
||||
"permissions": [
|
||||
"<all_urls>",
|
||||
"contextMenus",
|
||||
"privacy",
|
||||
"storage",
|
||||
"tabs",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"unlimitedStorage",
|
||||
"webNavigation",
|
||||
"activeTab"
|
||||
"webRequest",
|
||||
"activeTab",
|
||||
"webRequestBlocking",
|
||||
"<all_urls>"
|
||||
],
|
||||
"content_scripts": [
|
||||
{
|
||||
|
@ -48,6 +55,7 @@
|
|||
"content_scripts/dist/standards.js",
|
||||
"content_scripts/dist/defaults.js",
|
||||
"lib/storage.js",
|
||||
"lib/domainmatcher.js",
|
||||
"background_scripts/background.js"
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue