Last active
December 8, 2016 13:32
-
-
Save mlncn/2ca0b753358de353bf3828132b845681 to your computer and use it in GitHub Desktop.
Toggle fonts-loaded class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Toggle fonts-loaded | |
// @namespace agaric | |
// @description Toggle fonts loaded | |
// @include *.local | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
(function(){ | |
'use strict' | |
window.addEventListener('load', () => { | |
addButton('toggle fonts-loaded', toggleFontsLoaded) | |
}) | |
function addButton(text, onclick, cssObj) { | |
cssObj = cssObj || {position: 'absolute', bottom: '7%', left:'4%', 'z-index': 3} | |
let button = document.createElement('button'), btnStyle = button.style | |
document.body.appendChild(button) | |
button.innerHTML = text | |
button.onclick = onclick | |
Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key]) | |
return button | |
} | |
function toggleFontsLoaded() { | |
[...document.getElementsByTagName('html')].forEach(element => element.classList.toggle("fonts-loaded")) | |
} | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment