Skip to content

Instantly share code, notes, and snippets.

@wareya
Last active June 17, 2018 01:56
Show Gist options
  • Select an option

  • Save wareya/1cddf8627ff496b13d6ac906b8909f2f to your computer and use it in GitHub Desktop.

Select an option

Save wareya/1cddf8627ff496b13d6ac906b8909f2f to your computer and use it in GitHub Desktop.
Google Fonts preview override (gs script)
// ==UserScript==
// @name Google Fonts preview override
// @version 1
// @grant unsafeWindow
// @include https://fonts.google.com/*
// ==/UserScript==
function overwrite(e, text)
{
e.innerText = text;
unsafeWindow.angular.element(e.parentNode).controller('gfFontPreview').onFocusContentEditable();
}
function overwrite_text()
{
for(let e of document.querySelectorAll("gf-content-editable.font-preview-text"))
{
let replacetext =
//"When I jump down into the depths of the gorge, keep my dog from following.";
"I know my nemesis. And so, judging by my age, I'm no match for him.";
//"The quick brown fox jumps over the lazy dog.";
if(e.innerText != replacetext && document.activeElement != e)
{
overwrite(e, replacetext);
}
}
refresh_loop();
}
function refresh_loop()
{
lookup_timer = setTimeout(overwrite_text, 125);
}
refresh_loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment