Skip to content

Instantly share code, notes, and snippets.

@LouCypher
Last active August 29, 2015 13:56
Show Gist options
  • Save LouCypher/8979461 to your computer and use it in GitHub Desktop.
Save LouCypher/8979461 to your computer and use it in GitHub Desktop.
Stylish codes for keyconfig
stylishOverlay.addCode("");
const TITLE = "Write style for domain\u2026";
const promptSvc = Services.prompt;
function selectItems(aText, aArray) {
var selected = {};
var result = promptSvc.select(null, TITLE, aText, aArray.length, aArray, selected);
if (result)
return selected.value;
return false;
}
var domain = null;
try {
domain = content.document.domain;
} catch (ex) {}
if (!domain) { // URL has no domain (file/data/about/chrome scheme)
stylishOverlay.addSite(); // Write style for current URL
return;
}
var domains = [];
stylishOverlay.getDomainList(content.document.domain, domains); // Get sub-domain(s)
if (domains.length === 1) { // If no sub-domain(s)
stylishOverlay.addDomain(domains[0]); // Write style for current domain
return;
}
// Select sub-domains
var index = selectItems("Select domain:", domains);
if (domains[index] !== undefined)
stylishOverlay.addDomain(domains[index]); // Write style for selected domain
stylishOverlay.addSite();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment