Tutorials & Resources Filter Block by Country Script

Discussion in 'Novel Updates Site Discussion' started by CrowFX, Aug 10, 2020.

  1. CrowFX

    CrowFX Active Member

    Joined:
    Sep 3, 2016
    Messages:
    17
    Likes Received:
    11
    Reading List:
    Link
    It's against the spirit of the creator's wishes of Novel Updates :blobpensive:, but As much as I want to stay quiet, I am really annoyed by the sheer number of Chinese Novels I saw everywhere I go. :blobdevil:

    The solution for that? I made a script. And no, this is not that Release Filter on the front page. :blobchristmas:

    Added Support for front page. Still needs to have country origin selected in options though. :blobconfounded:

    What is this script? :blobsanta:

    A simple script to hide results from countries where the user can choose to block. It does not modify, nor does call the HTTP request at all, it's just a simple hiding script. So if you say, block results from China, the result for that page may suddenly turn to 0 because all the novel result in that page coincidentally are all originated from china.

    I haven't tested aside from my own browser Firefox or Firefox Android but the script should work fine on modern browsers, unless you use the old IE. So your result may vary, please tell your issue on my github page.

    PLEASE NOTE: IT DOES NOT PLAY NICE ON FIREFOX ANDROID unless you use 'Request Desktop Site' . ViolentMonkey seems to not play well on mobile site, or perhaps there's a difference in html for mobile or desktop, as for why? Well I'm not sure myself. :blobhyperthink:

    Now Mobile is Supported :blobparty::blobparty::blobparty:.

    The cause for broken script in mobile is the fact extra script will run to modify the page depending on the User Agent. User Agent identified as Android or iPhone will have javascript modify the page very drastically. Like instead of html element with tag table with id 'myTable' in desktop mode, suddenly there's a table with class 'tbl_m_release'. It's not ViolentMonkey having bad API, but NU implementation is causing the script to not found where to inject itself.

    Installation
    1. Install any of the Monkey Extension family, preferably ViolentMonkey since it's open source.
    2. Go to your account page > Click Site Settings tab > then check Enable Origin Tagging.
    3. Go to greasyfork script page and click install.
    4. Go to home (or if already there, refresh) and you should see the script already in effect.
    [​IMG]
    [​IMG]

    [​IMG]

    Update 1.2.0:
    1. Added mobile support

    Update 1.1.0:

    1. Changed checkbox to buttons
    2. Now support home (Need Origin tagging enabled)

    Source Code:

    1. Typescript (The real source code) :blobsmilehappyeyes:
    2. Javascript (You want to read ugly compiled code?) :blob_coughblood:
    License: MIT a.k.a. You can do anything to this script, just credit (or give star in github page) if you like it and don't sue me. :blobpopcorn_cool:
     
    Last edited: Aug 18, 2020
  2. UnGrave

    UnGrave ななひ~^^

    Joined:
    Jun 27, 2016
    Messages:
    4,072
    Likes Received:
    12,832
    Reading List:
    Link
    I've been thinking it would be nice to have a script that automatically adds all Chinese novels to my "Blocked" reading list which is set to hide everything in it from the home page. I've been meaning to sit down and make it, but I've been busy lately so anyone else who wants to steal my idea is welcome to do so, since that will make it permanent, and cross platform.
     
  3. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    I still think the easiest way is just to do this:

    https://forum.novelupdates.com/threads/home-page-filter.101618/page-2#post-5513493

    Why? Most people have an adblocker installed, but they won't have any monkey extension.

    New firefox for android killed all the extensions, so until they are approved there are a limited amount but ublock is preinstalled. You can also use other browsers that have adblock in them like samsung for chrome.

    Of course you might see 0 results if the entire page is chinese novels, but a way around that is simply add the common tags.

    Overall, the front page has far less scrolling then the releases page.
     
  4. CrowFX

    CrowFX Active Member

    Joined:
    Sep 3, 2016
    Messages:
    17
    Likes Received:
    11
    Reading List:
    Link
    If there's API documentation somewhere, I can go take a look at it.

    Digging through the JS code will take a while from the browser, and may waste too much time.

    There's hope for this idea even if there's no public documentation, unless this site is using Server Side Rendering, or compiled like React / Vue, since it's unlikely I can see the calling functions easily.

    Still to much work in my opinion, and too many goes through the filter. With this script I can just click once, and boom, painless filter. And also monkey extension is just using clicks to install. if they bother to search how to filter stuff, they probably have enough bothers to install, or if not, well their loss.

    For cross platform, it's dead end currently if using Monkey. But I can always just add to reading list stuff I want from desktop pc and read it in mobile just from the reading list.
     
  5. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    It's easier for most people than playing with monkey scripts. And it lets you go to latest chapter directly.

    But there is a simple way how you can make it more worth it for people while at same time fit ungrave's request.

    You don't need to go through any APIs. All you have to do is simple, when someone visits the home page, redirect them to the series page. But add an extra query parameter in the query string. Then make the series page look like the front page if the parameter is there. Maybe make it more interactive so that someone can view more info on mouseover without clicking.
     
    Last edited: Aug 10, 2020
  6. AliceShiki

    AliceShiki 『Ms. Tree』『Magical Girl of Love and Justice』

    Joined:
    Apr 27, 2016
    Messages:
    24,647
    Likes Received:
    98,366
    Reading List:
    Link
    There is none I'm afraid.
     
  7. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    To give you an example, try running this in console on the series or search page:

    Code:
    document.querySelectorAll('.search_main_box_nu').forEach(function (node) {  node.style.display = 'none'; document.querySelector('.w-blog-content, .w-blog-list').append(node.getElementsByClassName('search_title')[0]);  console.log(   node.getElementsByClassName('search_title')[0] )   })
    It's a rough example but that is the point. You would also have to add a parameter so that you can emulate going to latest chapter. But I would also put the rating upfront so people can see that without clicking.
     
  8. CrowFX

    CrowFX Active Member

    Joined:
    Sep 3, 2016
    Messages:
    17
    Likes Received:
    11
    Reading List:
    Link
    I'm not really an expert on front end stuff when using script injections things. So where do I even start to inject the script (aside from using Monkey of course)?
     
  9. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    right click, inspect, then go to console.

    The console is more than just to see errors, it lets you inject javascript. So it's a quick way to test your code.
     
  10. CrowFX

    CrowFX Active Member

    Joined:
    Sep 3, 2016
    Messages:
    17
    Likes Received:
    11
    Reading List:
    Link
    I mean injecting script for other users aside using Monkey. Other way I know is making a web scraper CLI, but that's outside the browser.

    :blobpensive::blobpensive: Ugh, nothing dampens a dev more than there's no documentation for something you want to build.

    I looked at the page source then found there's something called 'nonce' :blobangery:. It just gone from hopeful to just plain unlikely to develop magic button to block stuff for real without any api docs. Nonce will be a blockade to getting user Auth. No auth will mean no user impersonate and that also means no permission to edit user lists. :blobpensive: So no magic block button until I know how to get pass the auth.
     
    Last edited: Aug 11, 2020
  11. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    Are you talking about alternatives? Well the easiest option is simply css removal via adblocker. Followed by extensions, followed by monkey.
     
  12. CrowFX

    CrowFX Active Member

    Joined:
    Sep 3, 2016
    Messages:
    17
    Likes Received:
    11
    Reading List:
    Link
    So I've edited the script to support front page filter (no more source code editing for filtering countries in front page like Novel Updates Filter did). And the lack of the script's JQuery, and some non-native script overhead should be nice too.

    I also changed checkboxes to buttons because THIS F:blobcurse:G CSS on home page ruin my checkboxes. Also with buttons there should be an improvement to UX because of bigger area of click :blobangel:.

    [​IMG]
     
  13. CrowFX

    CrowFX Active Member

    Joined:
    Sep 3, 2016
    Messages:
    17
    Likes Received:
    11
    Reading List:
    Link
    What do you mean? Of course it's working. I don't release not working product.
     
    AngryOnion likes this.
  14. AngryOnion

    AngryOnion Well-Known Member

    Joined:
    Jul 5, 2016
    Messages:
    3
    Likes Received:
    1
    Reading List:
    Link
    Hi, CrowFX. The script works fine in the home page but when I browse these page, the script stopped working and I can still see all the novel that I don't want to see. I'm using the latest Firefox browser with Tampermoneky with the script from the first post of this thread.
    www(dot)novelupdates(dot)com/novelslisting/
    www(dot)novelupdates(dot)com/series-ranking
    www(dot)novelupdates(dot)com/latest-series/
     
    Last edited: Aug 23, 2020
  15. Ral

    Ral Not a Well-Known Member ¯\_(ツ)_/¯

    Joined:
    Dec 5, 2016
    Messages:
    1,214
    Likes Received:
    922
    Reading List:
    Link
    Doesn't work for me at all.

    I don't really need the addon - I just installed it to see if I had the same problem Onion does, but it turns out it's even worse for me xD
     
  16. AnnieCos990

    AnnieCos990 New Member

    Joined:
    Sep 27, 2020
    Messages:
    5
    Likes Received:
    0
    Reading List:
    Link
    I tried it too, doesn't work...
     
  17. Ral

    Ral Not a Well-Known Member ¯\_(ツ)_/¯

    Joined:
    Dec 5, 2016
    Messages:
    1,214
    Likes Received:
    922
    Reading List:
    Link
    He hasn't logged in in almost two months...

    If you don't need the menu for easy switching between languages, blocking one (or more) language can be done fairly easily with uBlock Origin filters (you can temporarily disable cosmetic filters to see them again, or just remove the filters).
    1. Click anywhere on NU to block an element with uBO.
    2. Replace text in the window with:
    Code:
    ##div.search_main_box_nu:has(span:has-text(/CN|JP|KR/))
    This removes Chinese, Japanese and Korean from most of the website.
    Change to this for just Chinese:
    Code:
    ##div.search_main_box_nu:has(span:has-text(/CN/))
    As you can see, new languages need to be added after a |.
    3. For the main page:
    Code:
    ##tr:has(span:has-text(/CN|JP|KR/))
    Works the same way as above. Just Chinese:
    Code:
    ##tr:has(span:has-text(/CN/))
     
    sbonyx, AngryOnion and Chrono Vlad like this.
  18. Chrono Vlad

    Chrono Vlad 『Banned From Drinking』

    Joined:
    May 24, 2017
    Messages:
    2,502
    Likes Received:
    4,706
    Reading List:
    Link
    Nice! I also blocked the ratings & reviews a while ago... Going YOLO :aww:
     
  19. AngryOnion

    AngryOnion Well-Known Member

    Joined:
    Jul 5, 2016
    Messages:
    3
    Likes Received:
    1
    Reading List:
    Link
    Ah, It works just fine now thank you @CrowFX . It seems the previous bug have been fixed and now it works fine on all those page. I grabbed the script from here www(dot)greasyfork(dot)org/en/scripts/408524-novel-updates-filter-result-by-country