From 4d309d43d2838599a8526cce15211eef8188bb26 Mon Sep 17 00:00:00 2001 From: jspenguin2017 Date: Wed, 7 Nov 2018 20:12:25 -0700 Subject: [PATCH] https://github.com/NanoAdblocker/NanoFilters/issues/218 Also remove old & broken webnovel.com and fox.com rules --- src/content/debug.js | 128 ++-------------------------------- src/content/rules-specific.js | 9 --- src/manifest.json | 2 +- 3 files changed, 8 insertions(+), 131 deletions(-) diff --git a/src/content/debug.js b/src/content/debug.js index 008c4f614f..8633c1a893 100644 --- a/src/content/debug.js +++ b/src/content/debug.js @@ -57,7 +57,6 @@ if (a.debugMode) { /*************************************************************************/ // Partially working - if (a.domCmp(["hulu.com"])) { const performClick = (btn) => { if (btn.classList.contains("nano-defender-clicked")) { @@ -86,128 +85,15 @@ if (a.debugMode) { /*************************************************************************/ - if (a.domCmp(["fox.com"])) { - // https://github.com/jspenguin2017/uBlockProtector/issues/660 - a.replaceXHR(() => { - - console.warn("[Nano] xhr", url); - - if (url.includes("uplynk.com/preplay")) { - this.addEventListener("readystatechange", () => { - if (this.readyState === 4) { - try { - - console.warn(this.responseText); - - let payload = window.JSON.parse(this.responseText); - payload.ads = {}; - replace(this, window.JSON.stringify(payload)); - } catch (err) { } - } - }); + // https://github.com/NanoAdblocker/NanoFilters/issues/218 + if (a.domCmp(["di.fm", "jazzradio.com"])) { + a.loopbackXHR((ignored, url) => { + if (url.startsWith("https://pubads.g.doubleclick.net/")) { + return ` + +`; } }); - a.inject(() => { - "use strict"; - const _fetch = window.fetch; - window.fetch = (...args) => { - - console.warn("[Nano] fetch", args); - - return _fetch.apply(window, args); - }; - }); - } - - /*************************************************************************/ - - if (a.domCmp(["webnovel.com"])) { - // https://github.com/jspenguin2017/uBlockProtector/issues/457 - const bookExtractor = /\/book\/([^/]+)/; - let isInBackground = false; - const scanner = () => { - if (isInBackground) { - return; - } - $(".cha-content._lock").each((lock) => { - lock.classList.remove("_lock"); - const video = lock.closest(".chapter_content").querySelector(".lock-video"); - if (video) { - video.remove(); - } - - const contentElem = lock.querySelector(".cha-words"); - contentElem.insertAdjacentHTML("beforeend", "

" + - "Nano Defender is fetching the rest of this chapter, this can take up to 15 seconds.

"); - - const bookID = bookExtractor.exec(location.href)[1]; - const chapterID = lock.querySelector("[data-cid]").dataset.cid; - if (!bookID || !chapterID) { - return; - } - const cookie = encodeURIComponent(a.cookie("_csrfToken")); - - $.request({ - method: "GET", - url: `https://www.webnovel.com/apiajax/chapter/GetChapterContentToken?_csrfToken=` + - `${cookie}&bookId=${bookID}&chapterId=${chapterID}`, - }, (data) => { - try { - let token = JSON.parse(data).data.token; - token = encodeURIComponent(token); - fetchChapter(cookie, token, contentElem); - } catch (err) { - console.error("[Nano] Failed :: Find Chapter Token"); - } - }, () => { - console.error("[Nano] Failed :: Find Chapter Token"); - }); - }); - }; - const fetchChapter = (cookie, token, contentElem) => { - const tick = () => { - $.request({ - method: "GET", - url: `https://www.webnovel.com/apiajax/chapter/GetChapterContentByToken?_csrfToken=` + - `${cookie}&token=${token}`, - }, (data) => { - try { - const content = JSON.parse(data).data.content.trim(); - if (content) { - contentElem.innerHTML = content; - setTimeout(() => { - drawChapter(content, contentElem); - }, 500); - } else { - setTimeout(tick, 2000); - } - } catch (err) { - setTimeout(tick, 2000); - } - }, () => { - setTimeout(tick, 2000); - }); - }; - tick(); - }; - const drawChapter = (content, contentElem) => { - if (!contentElem.innerHTML.includes("

")) { - const lines = content.split("\n"); - contentElem.innerHTML = ""; - for (let i = 0; i < lines.length; i++) { - const line = lines[i].trim(); - if (!line) { - continue; - } - const p = document.createElement("p"); - p.textContent = line; - contentElem.append(p); - } - } - }; - setInterval(scanner, 1000); - a.on("focus", () => { isInBackground = false; }); - a.on("blur", () => { isInBackground = true; }); } /*************************************************************************/ diff --git a/src/content/rules-specific.js b/src/content/rules-specific.js index c1eec2bc50..bacae6aeef 100644 --- a/src/content/rules-specific.js +++ b/src/content/rules-specific.js @@ -2121,15 +2121,6 @@ if (a.domCmp(["itv.com"])) { } }); } -if (a.domCmp(["di.fm", "jazzradio.com"])) { - a.loopbackXHR((ignored, url) => { - if (url.startsWith("https://pubads.g.doubleclick.net/")) { - return ` - -`; - } - }); -} if (a.domCmp(["stream.nbcsports.com"])) { a.loopbackXHR((ignored, url) => { if (url.includes(".v.fwmrm.net/ad/g/1")) { diff --git a/src/manifest.json b/src/manifest.json index a6aa0023c7..0c8f23897d 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -54,7 +54,7 @@ "webRequest", "webRequestBlocking" ], - "version": "15.0.0.70", + "version": "15.0.0.71", "web_accessible_resources": [ "resources/*" ]