Skip to content

Instantly share code, notes, and snippets.

@ahmedazhar05
Last active December 12, 2021 17:30
Show Gist options
  • Save ahmedazhar05/4e332c4ab8bf9ca1ba40ee380d7e3c70 to your computer and use it in GitHub Desktop.
Save ahmedazhar05/4e332c4ab8bf9ca1ba40ee380d7e3c70 to your computer and use it in GitHub Desktop.
https://book.marklet.ml/scribd Bookmarklet: Reveal pages in Scribd documents
javascript: (function() {
const version = '1.2';
if (document.URL.startsWith("https://www.scribd.com/doc")) {
let btn = document.createElement("BUTTON"), nv = "";
btn.className = "wrapper__filled-button download_btn";
btn.innerHTML = "Reveal";
btn.style.cssText = 'position:fixed;width:117px;z-index:59;bottom:14vh;right:10vw';
btn.onclick = () => {
window.scrollTo(0, 0);
let o = document.createElement("DIV");
o.innerHTML = `<div style="user-select:none;text-shadow:grey 2px 2px 2px;font:italic bold 50px Georgia, serif;color:white;">Scanning the Document...</div>` + nv;
document.body.appendChild(o);
o.style.cssText = 'position:fixed;display:flex;inset:0;background-color:#000000dd;z-index:60;cursor:progress;justify-content:center;align-items:center;';
let t = setInterval(() => {
if(window.pageYOffset >= document.body.scrollHeight - window.innerHeight - 5){
clearInterval(t);
[...document.getElementsByClassName("promo")].forEach(e => {e.remove()});
[...document.getElementsByClassName("auto__doc_page_webpack_doc_page_blur_promo")].forEach(e => {e.parentElement.remove()});
document.querySelectorAll(".text_layer .ie_fix div, .text_layer .ie_fix span").forEach(e => {e.style.color = "#000"});
[...document.getElementsByClassName("highlighter_canvas")].forEach(e => {e.remove()});
[...document.getElementsByClassName("absimg")].forEach(e => {e.style.opacity = 1});
[...document.getElementsByClassName("text_layer")].forEach(e => {e.style.textShadow = "none"});
document.querySelectorAll(".outer_page_container *[unselectable=on]").forEach(e => {e.removeAttribute("unselectable")});
window.scrollTo(0, 0);
btn.remove();
o.remove();
} else {
if(window.pageYOffset >= 0.9 * document.body.scrollHeight)
o.firstElementChild.innerText = "Done!";
else if(window.pageYOffset >= 0.8 * document.body.scrollHeight)
o.firstElementChild.innerText = "Almost Done...";
window.scrollBy(0, 20);
}
}, 1);
};
document.body.append(btn);
fetch('https://api.github.com/gists/4e332c4ab8bf9ca1ba40ee380d7e3c70')
.then(res => res.json())
.then(data => {
let v = data.files['scribd_reveal.js'].content.match(/version\s?=\s?(.)([\d\.]+)\1;/)?.[2];
if(v != version){
nv = `<a style="color:antiquewhite;font-size:1.5em;font-family:sans-serif;font-weight:bold;" href="http://book.marklet.ml/scribd" target="_blank">new version available v${v}</a>`;
}
});
} else alert("This Feature only works with Scribd Documents");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment