NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @namespace https://openuserjs.org/users/mwalcott3 // @name Webnovel.com Ad Bypass // @description Testing out a method to bypass ads on webnovel.com // @copyright 2017, mwalcott3 (https://openuserjs.org/users/mwalcott3) // @license MIT; https://opensource.org/licenses/MIT // @version 0.0.3 // @match https://www.webnovel.com/book/*/* // @run-at document-end // @grant none // ==/UserScript== // ==OpenUserJS== // @author mwalcott3 // ==/OpenUserJS== (function() { //'use strict'; // TODO error handling and better formatting for the non rich text content function bypassLock() { [...document.querySelectorAll('div.chapter_content[class*="j_lock_chap"')].forEach( (el)=>{ let csrfToken = /_csrfToken=([^;]+)/.exec(document.cookie)[1]; let bookId = el.querySelector('[data-bid]').dataset.bid; let chapterId = el.querySelector('[data-cid]').dataset.cid; let url = 'https://www.webnovel.com/apiajax/chapter/GetChapterContentToken?_csrfToken=' + csrfToken +'&bookId=' + bookId + '&chapterId=' + chapterId; el.classList.forEach( (className) => className.startsWith('j_lock_chap') ? el.classList.remove(className) : null ); el.querySelector('div.lock-video').remove(); el.querySelector('div.cha-content').classList.remove('_lock'); el.querySelector('div.cha-words').innerHTML = ""; fetch(url).then( (response) => response.json() ).then( (result)=> { let token = result.data.token; let url = 'https://www.webnovel.com/apiajax/chapter/GetChapterContentByToken?_csrfToken=' + csrfToken + '&token=' + token; setTimeout( () => { fetch(url).then((response) => response.json() ).then( (result)=> { console.log(result); if (result.data.isRichFormat) { el.querySelector('div.cha-words').innerHTML = result.data.content; } else { // TODO: Do this with ptags and a docFrag instead // Split then map el.querySelector('div.cha-words').innerHTML = result.data.content.replace(/\r?\n/g, '<p></p>'); } }); },3500); }); }); } let target = document.querySelector('div.j_contentWrap'); console.log(target); let observer = new MutationObserver(function(mutations) { bypassLock(); }); bypassLock(); observer.observe(target, {childList: true}); })();