Skip to content

Instantly share code, notes, and snippets.

@vonHabsi
Created February 14, 2019 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vonHabsi/57f95e37102b4272a4755392e64ee50e to your computer and use it in GitHub Desktop.
Save vonHabsi/57f95e37102b4272a4755392e64ee50e to your computer and use it in GitHub Desktop.
JS for Hotkey Driven Sidebar Display (thepante)
// ==UserScript==
// @name userChrome.js
// @include main
// @version 0.8.1.vH
// @note u/thepante
// ==/UserScript==
document.getElementById("sidebar").src='chrome://browser/content/webext-panels.xul';
document.getElementById("sidebar-button").checked=false;
var alfs = document.getElementById("sidebar-box");
var ogclass = alfs.className;
var statbnt = 0;
alfs.hidden=false;
alfs.checked=true;
alfs.className = ogclass + ' closeit';
document.getElementById("sidebar-button").addEventListener('click', function(e){
event.preventDefault();
if (statbnt == 0) {
console.log(statbnt+" : alfs open");
document.getElementById("sidebar-button").checked=true;
alfs.className = ogclass + ' openit';
alfs.hidden=false;
statbnt = 1;
}
else {
console.log(statbnt+" : alfs close");
document.getElementById("sidebar-button").checked=false;
alfs.className = ogclass + ' closeit';
alfs.hidden=true;
statbnt = 0;
}
});
/* Alt-Char */
/* a = 65, 0 = 48 */
document.onkeyup = function(e) {
if (e.altKey && e.which == 74) {
doitmf();
}
};
function doitmf() {
if (statbnt == 0) {
console.log(statbnt+" : alfs open");
document.getElementById("sidebar-button").checked=true;
alfs.className = ogclass + ' openit';
alfs.hidden=false;
statbnt = 1;
}
else {
console.log(statbnt+" : alfs close");
document.getElementById("sidebar-button").checked=false;
alfs.className = ogclass + ' closeit';
alfs.hidden=false;
statbnt = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment