Skip to content

Instantly share code, notes, and snippets.

@ryardley
Forked from michaeltaranto/bookmarklet.js
Last active April 21, 2017 04:12
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 ryardley/ac10938154af19cde11d23655dffcc59 to your computer and use it in GitHub Desktop.
Save ryardley/ac10938154af19cde11d23655dffcc59 to your computer and use it in GitHub Desktop.
Baseline Bookmarklet
javascript:(function () {
var BASE_PIXELS = 8;
var baselineNode = document.querySelector(".baseliner-overlay");
if (baselineNode) {
baselineNode.remove();
return;
}
var body = document.body,
html = document.documentElement,
height = Math.max(body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight);
var baselineOverlay = document.createElement("div");
baselineOverlay.className = "baseliner-overlay";
baselineOverlay.style.position = "absolute";
baselineOverlay.style.top = 0;
baselineOverlay.style.right = 0;
baselineOverlay.style.left = 0;
baselineOverlay.style.height = height + "px";
baselineOverlay.style.backgroundSize = "100% " + (BASE_PIXELS * 2) + "px";
baselineOverlay.style.backgroundImage = "linear-gradient(to bottom,rgba(0,0,0,0.08) 50%,rgba(0, 0, 0, 0) 8%,rgba(0, 0, 0, 0) 100%)";
baselineOverlay.style.zIndex = 20000;
baselineOverlay.style.content = '';
baselineOverlay.style.pointerEvents = "none";
document.body.appendChild(baselineOverlay);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment