37 lines
1.6 KiB
JavaScript
37 lines
1.6 KiB
JavaScript
|
// based on https://support.mozilla.org/en-US/questions/1378404#answer-1510431
|
||
|
try {
|
||
|
const hotkeys_to_disable = [
|
||
|
'openFileKb',
|
||
|
'key_savePage',
|
||
|
'printKb',
|
||
|
'key_close',
|
||
|
'key_closeWindow',
|
||
|
'key_toggleMute',
|
||
|
'key_reload',
|
||
|
'key_reload_skip_cache',
|
||
|
'key_quitApplication',
|
||
|
];
|
||
|
new (class {
|
||
|
attributes_to_remove = ['command', 'key', 'modifiers', 'oncommand', 'data-l10n-id'];
|
||
|
services = globalThis.Services || ChromeUtils.import('resource://gre/modules/Services.jsm').Services;
|
||
|
re_href = /^(chrome:(?!\/\/(global\/content\/commonDialog|browser\/content\/webext-panels)\.x?html)|about:(?!blank))/i; // whatever, I'm not refactoring this
|
||
|
constructor() { if (!this.services.appinfo.inSafeMode) this.services.obs.addObserver(this, 'chrome-document-global-created', false); }
|
||
|
observe(w) { w.addEventListener('DOMContentLoaded', this, {once: true}); } // Tempting to check location here, but we don't have it yet
|
||
|
handleEvent(e) {
|
||
|
const D = e.originalTarget, W = D.defaultView, L = W.location;
|
||
|
if (!L || !this.re_href.test(L.href)) return;
|
||
|
if (!W._gBrowser && !W.Tabbrowser) return; // https://bugzilla.mozilla.org/show_bug.cgi?id=1930654
|
||
|
//displayError('debug', '[ ' + L.href + ' | ' + W.document.getElementById('key_reload') + ' ]');
|
||
|
hotkeys_to_disable.forEach(n => {
|
||
|
const k = W.document.getElementById(n);
|
||
|
//displayError('debug', '[ ' + n + ' | ' + k + ' ]');
|
||
|
if (k !== null) this.attributes_to_remove.forEach(a => k.removeAttribute(a));
|
||
|
});
|
||
|
}
|
||
|
})()
|
||
|
} catch (e) {
|
||
|
displayError('hackmaster', e);
|
||
|
}
|
||
|
|
||
|
lockPref("hackmaster.autoconfig.loaded", "a miracle, really");
|