Qidian AdBlock

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

  1. Jeebus

    Jeebus Well-Known Member

    Joined:
    Jun 20, 2017
    Messages:
    904
    Likes Received:
    780
    Reading List:
    Link
    You're talking about the premium paywall. There's no script to get around that. Read my post here: https://forum.novelupdates.com/threads/qidian-adblock.43828/page-8#post-3738529
    Also, read the thread or at least the last page or two before posting. This issue has already been discussed a few times in this thread.
     
  2. mrttao

    mrttao Well-Known Member

    Joined:
    Aug 23, 2016
    Messages:
    2,723
    Likes Received:
    1,588
    Reading List:
    Link
    You are only supposed to do one at a time. if you try to do many at once it doesn't work.
    This applies on whether you are watching the ad or using the script. do it one at a time.

    Open one, wait 5 seconds for it to load, move to next chapter, wait 5 seconds for it to load, repeat.
     
  3. craterman

    craterman Well-Known Member

    Joined:
    Aug 19, 2016
    Messages:
    32
    Likes Received:
    24
    Reading List:
    Link
    thats not what im talking about, i only open one at a time, I was saying if I open multiple at a time of the same chapter, some load some dont, if it doesnt block the qidian ad reloading doesnt work, I have to close and reopen the page again and hope it works
     
  4. Jeebus

    Jeebus Well-Known Member

    Joined:
    Jun 20, 2017
    Messages:
    904
    Likes Received:
    780
    Reading List:
    Link
    Have you tried what I recommended? Use another browser, use another script manager, clear your cache, etc. Try to narrow down what, exactly, is causing the issue. Right now, you seem to be the only one experiencing the issue, and we have no way to help you if you aren't doing anything to narrow down what's causing it.
     
  5. craterman

    craterman Well-Known Member

    Joined:
    Aug 19, 2016
    Messages:
    32
    Likes Received:
    24
    Reading List:
    Link
    Well it worked fine before the qidian spiritstone update, I have used multiple script managers as well, just installed it on chrome and its working fine, breaks the only pay with spirit stone chapters, not that I care.
     
  6. mrttao

    mrttao Well-Known Member

    Joined:
    Aug 23, 2016
    Messages:
    2,723
    Likes Received:
    1,588
    Reading List:
    Link
    ... that is LITERALLY what I was answering.
    Some load, some don't. because of how tokens work. scroll slower, let a chapter fully load properly before scrolling to the other one.

    honestly though, i disabled it entirely. its quicker to use spirit stones. every day you get free spirit stones enough to unlock 3 chapters. and they expire if not used so... just use them
     
  7. craterman

    craterman Well-Known Member

    Joined:
    Aug 19, 2016
    Messages:
    32
    Likes Received:
    24
    Reading List:
    Link
    im not talking about scrolling down the chapter, I middle click the chapters so it opens in a new tab on the chapter I want to read, and if said chapter has an ad it might glitch and not go away...
     
  8. mrttao

    mrttao Well-Known Member

    Joined:
    Aug 23, 2016
    Messages:
    2,723
    Likes Received:
    1,588
    Reading List:
    Link
    When I explicitly answered you about opening it in new windows you said you are not talking about opening new windows but about scrolling down a chapter. Now that I told you the same thing applies you are saying that you aren't scroll and are back to opening new windows.

    I am thinking you are trolling me instead of looking for actual answers with this flip flop. You are also completely ignoring the part where I already repeatedly told you it applies to both. Whether opening new windows or scrolling down, only one ad can be "processed" at a time.

    The ad is not going away because another ad was loaded which intentionally prevents the previous one from loading the chapter. not because of a "glitch". this is working as intended. Since obvious if you are "watching" 10 ads at once you are not watching any of them at all and instead have just opened a bunch of chapters to quickly skip the ads on them all

    The script can't change this fact, it can only hide the ad and rapidly skip it faster than watching it manually would. but it can still only do 1 at a time.
     
  9. craterman

    craterman Well-Known Member

    Joined:
    Aug 19, 2016
    Messages:
    32
    Likes Received:
    24
    Reading List:
    Link
    -_- I just checked my previous comments and no I didn't ever say anything about scrolling down chapters was when this problem occurred and when I talk about opening multiple chapters at once I'm using that as a test to see how often this glitch occurs AS when I use another browser like say chrome I can spam open a bunch of ad walled chapters and they all load fine
     
  10. kitame

    kitame Well-Known Member

    Joined:
    Feb 11, 2017
    Messages:
    389
    Likes Received:
    127
    Reading List:
    Link
    I noticed that the ad' timer was literally in deciseconds, if you press "skip" right after the timer ends it just shows a blank page, the solution is to wait for about 8seconds before pressing "skip".
     
  11. tomptypl

    tomptypl Active Member

    Joined:
    Apr 16, 2016
    Messages:
    2
    Likes Received:
    0
    Reading List:
    Link
    @Jeebus

    Thanks for the script! I've used it since the first day they wanted me to watch a video ad.

    Is there a way to automatically make the script not run on the premium-only chapters?

    I can still click the unlock button, but I then have to reload the page, which is annoying, as I then have to find my place again, thanks to the way they dynamically load chapters.

    I've been using @exclude for each premium novel I read, but having to add each new one is annoying, and it seems to me that there should be a way to do it from within the script itself.

    Here's what I've figured out so far:
    The chapters with video ads have: <div class="iso-area j_locked_chap" data-vtype="1">
    While the premium chapters have: <div class="iso-area j_locked_chap" data-vtype="2">

    Unfortunately, I don't know how to use this information to make the necessary changes to the script.

    As a bonus, which I realize which would be an entirely different solution that not everyone would be interested in using, I don't suppose there's a way to automatically select the unlock button (and spend the necessary Spirit Stones)?
    Clicking that button every time is so hard, after all.
     
  12. Jeebus

    Jeebus Well-Known Member

    Joined:
    Jun 20, 2017
    Messages:
    904
    Likes Received:
    780
    Reading List:
    Link
    @noisypixy made the script. I'm busy with work for the next few days, so I won't have time to look at it. I'll try to get around to it later in the week.
     
    Last edited: Apr 29, 2018
  13. tomptypl

    tomptypl Active Member

    Joined:
    Apr 16, 2016
    Messages:
    2
    Likes Received:
    0
    Reading List:
    Link
    Heh. Indeed. Clicking the button to go back to the first page and double check was too hard, apparently.
     
  14. noisypixy

    noisypixy Sacatunn que pen, que summum que tun.

    Joined:
    Jun 25, 2016
    Messages:
    716
    Likes Received:
    950
    Reading List:
    Link
    I don't use Qidian and don't have an account there, so unfortunately I don't think this is something I can test.

    But from your information, that should be fixed by putting this right at the beginning of the main forEach loop:

    Code:
    // Check whether the chapter is inside or outside the `<div data-vtype="2">` element.
    if (lock.closest('[data-vtype="2"]') || lock.querySelector('[data-vtype="2"]')) {
        return;
    }
    
    Since I don't know from your post whether that element is inside or outside I'm checking for both cases, but I don't think it'd cause any conflict either way.

    The script with the changes would be like this:
    Code:
    // ==UserScript==
    // @name        webnovel.com skip video ads
    // @namespace   http://forum.novelupdates.com/
    // @version     5
    // @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.
    //------------------------------------------------------------------------------
    
    // 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;
    
    /**
     * 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) => {
        if (lock.closest('[data-vtype="2"]') || lock.querySelector('[data-vtype="2"]')) {
            return;
        }
    
        // 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}`
        )
          .then(resp => resp.json())
          .then(data => data.data.token)
          .then(token => encodeURIComponent(token))
          .then(token => 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=${token}`;
    
              fetch(url)
                .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.stack);
          });
      });
    }
    
    // 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);
    
    If it doesn't work you'll have to wait for @Jeebus to fix it :)
     
    Kylarin, AliceShiki and mrttao like this.
  15. rdawv

    rdawv The Ancient of Lore

    Joined:
    Jan 18, 2016
    Messages:
    2,137
    Likes Received:
    7,349
    Reading List:
    Link
    Is this still working today? The ads got skipped, but the text remain gray and not fully loaded.
     
    Tembulon and bonifide like this.
  16. bonifide

    bonifide Well-Known Member

    Joined:
    Oct 20, 2015
    Messages:
    1,081
    Likes Received:
    484
    Reading List:
    Link
    I'm getting the same problem. lol
     
    Tembulon likes this.
  17. rdawv

    rdawv The Ancient of Lore

    Joined:
    Jan 18, 2016
    Messages:
    2,137
    Likes Received:
    7,349
    Reading List:
    Link
    Drats, was hoping to catch up on some quick reading while on the road.
     
  18. kay.lenson

    kay.lenson Deus ex machina

    Joined:
    Oct 20, 2015
    Messages:
    226
    Likes Received:
    61
    Reading List:
    Link
    It's working as usual, chapter's which are not loading are paid they needed power stones to access
     
    Auranyte likes this.
  19. Rethorian

    Rethorian Well-Known Member

    Joined:
    May 9, 2017
    Messages:
    81
    Likes Received:
    106
    Reading List:
    Link
    No, it's not working as usual, and it's not working on adwalled chapters, at least for me.

    And yes, i'm well aware of the difference between a 'Bonus Chapter' you need to watch ads for and a 'Locked Chapter' that requires stones.

    It's entirely possible and that's it some sort of addon/extension or browser based problem for the rest of us, but just because it's working for you doesn't mean it's working for everyone.

    And yes, I'll upload a screenshot of the clearly marked:

    Bonus chapter
    Read bonus chapter after this ad & support your translator

    Ad may contain sound. If there's an error with the ad, please check if AdBlock is active


    Along with the greyed out and half missing chapter if you really don't believe me.
     
    Tembulon likes this.
  20. Kilian

    Kilian Dao of Dreams

    Joined:
    Dec 22, 2015
    Messages:
    115
    Likes Received:
    89
    Reading List:
    Link
    Mine stopped working for me today as well.

    To clarify for others, it doesn't work for the advanced chapters (the one with the ads, I don't mean the premium chapters).
     
    Tembulon likes this.