HOWTO: disable master password auto prompt dynamically
Hi, this is not question but an answer :) While I was trying to figure out how I could get rid of the master password prompt that pops up on every page that I once saved the password for (because I often don't want to login on these pages, just take a look), I found many people asking this. The solution was the MasterPasswordPlus addon for Firefox which stopped working with Quantum.
So here's how to do it with webextensions. Please note that I did that just for myself and will not publish it because I'm to lazy to add all the error handling, do updates etc. I just provide this as is, and whoever wants to use it locally or maybe make an addon from it: please go ahead and use the code any way you want! I also post it here so that it can be found in Google for other people looking for this.
With these two files (get your own icons please) you will have a webextension that shows a little icon in the URL bar. When you click it, the "Remember logins and passwords for websites" options in the preferences will toggle on and off. When it's off, you won't be asked for the master password on sites that you stored before. When it's on, you get the popup asking for it. When it was off and you want your password filled in on a page, you have to switch it on and reload the page.
Very basic functionality, but maybe someone has fun extending it.
cu, Frank
manifest.json:
{ "description": "Dis-/enable the master password popup", "manifest_version": 2, "name": "NewMasterPasswordPlus", "version": "1.0", "icons": { }, "applications": { "gecko": { "id": "[email protected]" } }, "permissions": [ "activeTab", "tabs", "privacy" ], "background": { "scripts": ["background.js"] }, "page_action": { "default_icon": "icons/true.png", "browser_style": true } }
background.js:
function setIcon(tab, state){ if (state===true) { browser.pageAction.setIcon({tabId: tab.id, path: "icons/true.png"}); } else { browser.pageAction.setIcon({tabId: tab.id, path: "icons/false.png"}); } browser.pageAction.show(tab.id); } function updateIcon(tab) { var state=getState(); state.then((got) => { setIcon(tab,got.value); }); } function getState() { var getting = browser.privacy.services.passwordSavingEnabled.get({}); return getting; } function toggleState(tab) { var getting = browser.privacy.services.passwordSavingEnabled.get({}); getting.then((got) => { console.log('got:'+got.value); if ((got.levelOfControl === "controlled_by_this_extension") || (got.levelOfControl === "controllable_by_this_extension")) { var setting = browser.privacy.services.passwordSavingEnabled.set({ value: !got.value }); setting.then(() => { updateTabs();}); } else { console.log("Not able to set passwordSavingEnabled"); } }); } /* Update icon on all tabs */ function updateTabs(){ var gettingAllTabs = browser.tabs.query({}); gettingAllTabs.then((tabs) => { var state=getState(); state.then((got) => { for (let tab of tabs) { setIcon(tab,got.value); } }); }); } /* Each time a tab is updated, reset the page action for that tab. */ browser.tabs.onUpdated.addListener((id, changeInfo, tab) => { updateIcon(tab); }); /* Toggle when the page action is clicked. */ browser.pageAction.onClicked.addListener(toggleState); /* When first loaded, initialize the page action for all tabs. */ updateTabs();
由 cor-el 於
所有回覆 (1)
Hmm, too bad some of the indents and line breaks got crippled, the editor window didn't offer any code tags or sth. Anyway, you will be able to get it right in an editor :)