diff --git a/PasseiDiretoBypass/script.js b/PasseiDiretoBypass/script.js index 1736b095272357080881873f61a4fc1ae82f25de..33c89ebcd3cb011fc52c8c152c191637adb33854 100644 --- a/PasseiDiretoBypass/script.js +++ b/PasseiDiretoBypass/script.js @@ -2,7 +2,7 @@ // @name Passei Direto Bypass // @name:pt-BR Passei Direto Bypass // @namespace https://gitlab.com/Dwyriel -// @version 1.1.2 +// @version 1.2.0 // @description Changes a few things to remove the paywall card and unblur the answers. // @description:pt-BR Faz algumas modificações no site para remover a limitação e tirar o borrão do texto. // @author Dwyriel @@ -32,26 +32,64 @@ answerCard.innerHTML = text; } } + let handleSmallPage1 = null; + let handleSmallPage2 = null; + let handleBigPage1 = null; + let smallPageRemoveBlurFunc = null; function arquivoPageFix() { - function arquivoPageFixSmallWidth() { - function removeBlur() { - let nodes = document.querySelectorAll("[style*='filter: blur(10px)']"); - for (let node of nodes) { - let clonedNode = node.cloneNode(true); - clonedNode.classList.remove("paywall"); - clonedNode.style = "filter: blur(0px)"; - node.after(clonedNode); - node.remove(); - } + function removeBlur(element) { + let nodes = element.querySelectorAll("[style*='filter: blur(10px)']"); + for (let node of nodes) { + let clonedNode = node.cloneNode(true); + clonedNode.classList.remove("paywall"); + clonedNode.style = "filter: blur(0px)"; + node.after(clonedNode); + node.remove(); } - document.querySelectorAll("[class*='BannerSelector_banner-container']").forEach(ele => ele.remove()); - removeBlur(); - setTimeout(removeBlur, 100); - setTimeout(removeBlur, 1000); - addEventListener("scroll", removeBlur); } + function arquivoPageFixSmallWidth() { + smallPageRemoveBlurFunc = () => removeBlur(document); + removeBlur(document); + handleSmallPage1 = setTimeout(smallPageRemoveBlurFunc, 100); + handleSmallPage2 = setTimeout(smallPageRemoveBlurFunc, 1000); + addEventListener("scroll", smallPageRemoveBlurFunc); + } + function arquivoPageFixBigWidth() { + let images = [...document.querySelectorAll("img[loading='lazy'][class*='paywall']")]; + if (images.length > 0) + for (let image of images) + if (image.complete) { + image.setAttribute("loading", "eager"); + let PaywallParent = image.closest("[class*='paywall FileHtmlViewer_file-html-container']"); + let clonedNode = PaywallParent.cloneNode(true); + clonedNode.classList.remove("paywall"); + PaywallParent.after(clonedNode); + PaywallParent.remove(); + removeBlur(clonedNode); + } + handleBigPage1 = setTimeout(arquivoPageFixBigWidth, 200); + } + if (handleSmallPage1 != null) { + clearTimeout(handleSmallPage1) + handleSmallPage1 = null; + } + if (handleSmallPage2 != null) { + clearTimeout(handleSmallPage2) + handleSmallPage2 = null; + } + if (handleBigPage1 != null) { + clearTimeout(handleBigPage1) + handleBigPage1 = null; + } + if (smallPageRemoveBlurFunc != null) { + removeEventListener("scroll", smallPageRemoveBlurFunc); + smallPageRemoveBlurFunc = null; + } + document.querySelectorAll("[class*='BannerSelector_banner-container']").forEach(ele => ele.remove()); if (window.innerWidth <= 1280) arquivoPageFixSmallWidth(); + else + arquivoPageFixBigWidth(); } if (window.location.pathname.includes("pergunta")) perguntaPageFix();