Skip to content

Instantly share code, notes, and snippets.

@sheodox
Last active August 29, 2015 14:07
Show Gist options
  • Save sheodox/0458bfb313978a7bdb18 to your computer and use it in GitHub Desktop.
Save sheodox/0458bfb313978a7bdb18 to your computer and use it in GitHub Desktop.
Automatically changes the font to Meiryo for the chosen domains.
// ==UserScript==
// @name Auto-Meiryo
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @copyright 2012+, You
// ==/UserScript==
(function() {
var always = 'alwaysHost';
function styleMeiryo() {
var style = document.createElement('style');
style.textContent = '*{font-family:Meiryo !important;}';
document.body.appendChild(style);
}
function hasHost() {
return GM_getValue(always, []).indexOf(location.host) !== -1;
}
function addHost() {
var hosts = GM_getValue(always, []);
hosts.push(location.host);
GM_setValue(always, hosts);
}
function removeHost() {
var hosts = GM_getValue(always, []);
hosts.splice(hosts.indexOf(location.host), 1);
GM_setValue(always, hosts);
}
if (hasHost()) {
styleMeiryo();
GM_registerMenuCommand('Meiryo auto-styler: remove ' + location.host, function() {
removeHost();
});
}
else {
GM_registerMenuCommand('Meiryo auto-styler: add ' + location.host, function() {
addHost();
styleMeiryo();
});
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment