Last active
April 30, 2021 14:57
-
-
Save Plasmoxy/4c94b632222063bc2f9792981c35879b to your computer and use it in GitHub Desktop.
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 DARK PDF | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description dark theme for chrome pdf using L butotn on top | |
// @author Plasmoxy | |
// @include file:///* | |
// @icon https://www.google.com/s2/favicons?domain=undefined. | |
// @grant none | |
// ==/UserScript== | |
let vals = [0, 25, 50, 60, 70, 80, 90, 100] | |
let vali = 0 | |
window.d = function(widthPercent) { | |
if (document.getElementById("cover")) document.getElementById("cover").remove(); | |
let cover = document.createElement("div"); | |
cover.id = "cover"; | |
let rest = 100 - widthPercent; | |
let left = rest / 2 - 0.5; | |
let css = `box-sizing: border-box; position: fixed;pointer-events: none;top: 0;left: ${left}vw;width: ${widthPercent}vw;height: 100vh;background-color: #fafafa;mix-blend-mode: difference;z-index: 1;`; | |
cover.setAttribute("style", css); | |
document.body.appendChild(cover); | |
console.log("darkened to " + widthPercent); | |
} | |
let b = document.createElement("button") | |
b.onclick = () => { | |
vali = (vali + 1) % vals.length; | |
window.d(vals[vali]); | |
} | |
b.setAttribute("style", "position: fixed; top: 0; left: 0; z-index: 3;"); | |
b.innerText = "L" | |
document.body.appendChild(b); | |
console.log("ddark"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment