Qidian AdBlock

Discussion in 'Tech Discussion' started by noisypixy, Aug 1, 2017.

  1. jace1884

    jace1884 Active Member

    Joined:
    Jun 25, 2017
    Messages:
    4
    Likes Received:
    1
    Reading List:
    Link
    any updates to this?
     
  2. mitre27

    mitre27 Well-Known Member

    Joined:
    Jul 8, 2016
    Messages:
    613
    Likes Received:
    279
    Reading List:
    Link
    Possible to fix again?

    Possible to fix it again?
     
  3. Tembulon

    Tembulon Well-Known Member

    Joined:
    Oct 23, 2015
    Messages:
    11
    Likes Received:
    1
    Reading List:
    Link
    to all my brodas i found an alternative script on github. it might be full of vulnerabilities to your browser though so if an expert could review it i'd deeply appreciate but it does work


    https://adsbypasser.github.io
     
  4. Razinal

    Razinal Active Member

    Joined:
    Oct 29, 2015
    Messages:
    3
    Likes Received:
    1
    Reading List:
    Link
    Hi, @ekojsalim

    It seems that the updated script works no longer after getting the first 2 chapter's content.
    I've tested it in www . webnovel . com/book/9795095706003005
    and whether with violetmonkey or tampermonkey it seems to be stuck using the the token to get content. despite the fact it is supposed to check only once a second.
    I am logged in. using chrome 71 64-bit. and running updated win 10 v1803.

    Tampermonkey error:
    Code:
    TypeError: Cannot read property 'content' of undefined
    at fetch.then.then (userscript.html?id=8b124037-d2ea-4834-9cb1-f7267d3ddcc3:103)
    Violetmonkey Error:
    Code:
    TypeError: Cannot read property 'content' of undefined
    at fetch.then.then (:98:34)
    EDIT: I also tested this on Microsoft Edge 42.17134.1.0 w/ Microsoft EdgeHTML 17.17134 on Tampermonkey v4.8.5847 and got the same results.
    EDIT: More on Violetmonkey Error:
    When you expand the error this happens:
    Code:
    e.(anonymous function) | @ | raven.62118.js:1
    -- | -- | --
      | fetch.then.then.catch | @ | VM13443:107
      | Promise.catch (async) |   |
      | tick | @ | VM13443:106
      | fetch.then.then.catch | @ | VM13443:109
      | Promise.catch (async) |   |
      | tick | @ | VM13443:106
      | fetch.then.then.catch | @ | VM13443:109
      | Promise.catch (async) |   |
      | tick | @ | VM13443:106
      | fetch.then.then.catch | @ | VM13443:109
      | Promise.catch (async) |   |
      | tick | @ | VM13443:106
      | fetch.then.then.catch | @ | VM13443:109
      | Promise.catch (async) |   |
    ....and so on and on forever.
    raven.62118.js appears to be a script from www . yueimg . com loaded by www . webnovel . com .
     
    Last edited: Dec 12, 2018
  5. ekojsalim

    ekojsalim Active Member

    Joined:
    Feb 16, 2017
    Messages:
    8
    Likes Received:
    24
    Reading List:
    Link
    So, I finally came around and fixed this again, sorry. I kinda lost interest on Qidian novels for a while.
    Code:
    // ==UserScript==
    // @name        webnovel.com skip video ads
    // @namespace   http://forum.novelupdates.com/
    // @version     6
    // @run-at      document-end
    // @match       http://webnovel.com/book/*
    // @match       https://webnovel.com/book/*
    // @match       http://www.webnovel.com/book/*
    // @match       https://www.webnovel.com/book/*
    // ==/UserScript==
    //------------------------------------------------------------------------------
    // This script is released to the public domain. No attribution is required.
    //------------------------------------------------------------------------------
    
    // FIX - 5/6/18
    // I'm not sure why we need to explicitly pass _csrfToken here (since we specified credentials: include) but hey it works!
    //
    
    // How frequently this script should check for new chapters.
    //
    // The amount is in milliseconds.
    const INTERVAL_CHAPTER_CHECK = 1000;
    
    // When a token is not ready yet, this is how much time we should wait
    // before trying again.
    //
    // The amount is in milliseconds.
    const INTERVAL_TOKEN_CHECK = 1000;
    
    function getCookie(name) {
      var value = "; " + document.cookie;
      var parts = value.split("; " + name + "=");
      if (parts.length == 2) return parts.pop().split(";").shift();
    }
    
    /**
     * Check for new chapters and try to remove the adwall from them.
     */
    function main() {
      Array.from(
       // Locked chapters.
       document.querySelectorAll('.cha-content._lock')
      ).forEach((lock) => {
       // Remove this class so this chapter won't be processed the next time
       // `main` is called.
       lock.classList.remove('_lock');
    
       // Remove the video.
       const v = lock.closest('.chapter_content').querySelector('.lock-video');
       if (v) {
         v.remove();
       }
    
       // Element with the chapter content.
       const contentElement = lock.querySelector('.cha-words');
    
       contentElement.style.opacity = '0.1';
    
       // Get the ID for the series ("book").
       //
       // Some chapters have the `data-bid` property, but not all of them.
       // That's why it's better to just get this from the URL.
       const bid = window.location.href.split('/book/')[1].split('/')[0];
    
       // Get the ID for the chapter.
       const { cid } = lock.querySelector('[data-cid]').dataset;
    
       // Both ID are required.
       if (!bid || !cid) {
         return;
       }
       return fetch(
         `https://www.webnovel.com/apiajax/chapter/GetChapterContentToken?bookId=${bid}&chapterId=${cid}&_csrfToken=${getCookie("_csrfToken")}`
       , {credentials: "include"})
         .then(resp => resp.json())
         .then(data => {
         console.log(data);
         return {token, vipPrice} = data.data;
       })
         .then(data => { return {token: encodeURIComponent(token), vipPrice: encodeURIComponent(vipPrice)}})
         .then(data => new Promise((resolve) => {
           // The raw body of the chapter.
           //
           // It will be plain text, so we must manually build the HTML for it.
           let content = '';
    
           // Try to get the content of the chapter, and fulfill the promise once
           // we have it.
           //
           // This function will retry until it succeeds.
           function tick() {
             const url = `https://www.webnovel.com/apiajax/chapter/GetChapterContentByToken?token=${data.token}&_csrfToken=${getCookie("_csrfToken")}&price=${data.vipPrice}&unlockType=1&bookId=${bid}&chapterId=${cid}`;
    
             fetch(url, {credentials: "include"})
               .then(resp => resp.json())
               .then((data) => {
                 content = data.data.content.trim();
    
                 if (content) {
                   resolve(content);
                 } else {
                   setTimeout(tick, INTERVAL_TOKEN_CHECK);
                 }
               })
               .catch((err) => {
                 console.error(err.stack);
    
                 tick();
               });
           }
    
           tick();
         }))
         .then((content) => {
           // Build the HTML for the chapter content.
           //
           // For now we only split on line breaks and wrap each piece
           // with "<p></p>" tags.
           const chapterHtml = content
             .split('\n')
             .map(p => p.trim())
             .filter(p => !!p)
             .map(p => `<p>${p}</p>`)
             .join('');
    
           // Update the chapter content and turn opacity back to 100%.
           contentElement.innerHTML = chapterHtml;
           contentElement.style.opacity = '1';
         })
         .catch((err) => {
           console.error(err);
         });
      });
    }
    
    // Since Qidian may load new chapters without refreshing the page, we must
    // continuously check for new chapters in the page.
    setInterval(main, INTERVAL_CHAPTER_CHECK);
    
     
    moevora, An0N, Lovely and 1 other person like this.
  6. Nicolas

    Nicolas Well-Known Member

    Joined:
    Nov 1, 2015
    Messages:
    412
    Likes Received:
    523
    Reading List:
    Link
    Tried it just now on Super Gene ( https://www.webnovel.com/book/8022472105002805/26129802935195334/Super-Gene/Dongxuan-Sutra ) and doesn't look like it works
     
  7. ekojsalim

    ekojsalim Active Member

    Joined:
    Feb 16, 2017
    Messages:
    8
    Likes Received:
    24
    Reading List:
    Link
  8. Razinal

    Razinal Active Member

    Joined:
    Oct 29, 2015
    Messages:
    3
    Likes Received:
    1
    Reading List:
    Link
    Thankks, it works perfectly. ❤

     
  9. Nicolas

    Nicolas Well-Known Member

    Joined:
    Nov 1, 2015
    Messages:
    412
    Likes Received:
    523
    Reading List:
    Link
    Oh, shame.