Tutorials & Resources Novel Updates UserScript to preview cover images

Discussion in 'Novel Updates Site Discussion' started by sithkazar, Jan 9, 2017.

  1. Nazgand

    Nazgand New Member

    Joined:
    Oct 1, 2016
    Messages:
    480
    Likes Received:
    407
    Reading List:
    Link
    @sz A bug I have noticed is that sometimes the popup persists after taking the mouse off of all links. Maybe adding a timed function to check that the mouse is still above the link it thinks it is above will solve both bugs.
    Also, for those that do not speak German, use this link instead: https://greasyfork.org/en/scripts/26439-novelupdates-cover-preview
     
  2. sithkazar

    sithkazar Professional Screw Up

    Joined:
    Dec 14, 2015
    Messages:
    750
    Likes Received:
    944
    Reading List:
    Link
    Ah, sorry about that. I fixed it.

    The only thing I wish is that the box was able to adjust its size so it didn't take so much room if it doesn't need to, but that is more of a pet peeve rather then a bug. It looks great. Thanks for all your hard work!
     
  3. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    Changed link in my previous post and uploaded little bugfix release.
    I'll have to see if i can reproduce the persistent popup. On which page type did it happen? Index or group or individual serie page? Maybe after you narrow down the use case i can also find the bug appearance.

    Version 0.5.2
    • No more delayed loaded popup change cause of previous hover. Popup only gets refreshed when (currentTitelHover == suppressedNativTitle) -> So it should only refresh the popup on active hover

    If there is no new bug i'll look into size adjusted popups. Afterwards it should be ready for a version 1.0
     
    Last edited: Jan 12, 2017
    runsing, Nazgand and sithkazar like this.
  4. Nazgand

    Nazgand New Member

    Joined:
    Oct 1, 2016
    Messages:
    480
    Likes Received:
    407
    Reading List:
    Link
    Last time I saw the persistent popup, it was at http://www.novelupdates.com/readlist/?uname=akki , but I remember it happening on the homepage too, and on series pages. I just tested it, and it has improved between 0.5 and 0.5.2. In 0.5, the popup can incorrectly persist when the mouse is above the webpage, but in 0.5.2, the popup can only incorrectly persist when the mouse is not on the webpage; when I move the mouse back, it instantly disappears.
    Also, though I do not know if this counts as a bug, I think it should. E.g.: goto http://www.novelupdates.com/series/rebirth-of-the-thief-who-roamed-the-world/?pg=8 , or some other series that is not on page 1 of the chapters, and hover above the number 1, and the popup appears. My argument on why this should not happen is because the picture is already shown on the upper left of the page, and the popup also does not correctly show the title.
     
  5. sithkazar

    sithkazar Professional Screw Up

    Joined:
    Dec 14, 2015
    Messages:
    750
    Likes Received:
    944
    Reading List:
    Link
    I don't think you need to make an argument :) its definitely a bug. I guess its because the "1" button has the same link as the novel's default page.
     
    Nazgand likes this.
  6. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    If it is not as intended it is a bug ;)
    Bugfixed: narrowed down the selector to (.wpb_wrapper > a). @sithkazar is right. It was a link and inside the wrapper, but since it is enclosed in the pagination it can be circumvented by narrowing it down to direct links inside the wrapper.

    Bugfixed: Before now there was no check if the mouse has left the document. So when you alt tab and the mouse is outside of the window it had not gotten the mouseleave event of the link title. Should be the same fix for the public reading list (Still had not tested against such pages, but should be the same as index pages)

    released Version 0.5.6
    • document.mouseleave added
    • bugfixed: narrowed down selector to exclude serietitle of page one
    After further testing i am seeing that document.mouseleave has still not fixed the problem for chrome. Am further looking into it.

    released Version 0.5.8
    • chrome fix: added $(window).blur() for alt tab behaviour additional to document.mouseleave

    released Version 0.6
    • increased maxCacheAge to 24 hours
    • changed Recommendations popup to right side of wrapper border
    • changed popup resizing to min 400px height and width autosize
    • beginning to reduce code smells
     
    Last edited: Jan 12, 2017
    runsing, sithkazar and Nazgand like this.
  7. Nazgand

    Nazgand New Member

    Joined:
    Oct 1, 2016
    Messages:
    480
    Likes Received:
    407
    Reading List:
    Link
    As of 0.6, I can no longer see any obvious way in which the functionality could be improved. @sz Thank you for making this userscript.
     
    sithkazar likes this.
  8. sithkazar

    sithkazar Professional Screw Up

    Joined:
    Dec 14, 2015
    Messages:
    750
    Likes Received:
    944
    Reading List:
    Link
    I think you have done a great job @sz! I love it :D
     
    Nazgand likes this.
  9. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    There is still one big change :sneaky:

    Since it seemed stable i made a few more changes. Now added setting variables at the top. If you have got other sites it should be easier to adapt. At least there should be no need for a coder. A frontend developer should be able to get the right selectors.
    While testing with mangaupdates i also added an imageblocker setting. There you can write one unwanted image url which gets falsely pulled when there is no cover image.
    I made an example where i just changed the name and greasemonkey include urls and my variable settings to make it work with mangaupdates
    https://greasyfork.org/scripts/26513-mangaupdates-cover-preview

    Just released Version 1.0 (https://greasyfork.org/scripts/26439-novelupdates-cover-preview)
    • elevated to Version 1.0
    • increased MaxCacheAge to 7 days
    • further refactoring/reducing of code smells
    • added imageblocker
    • added setting variables -> easier to adapt to other sites instead of looking through the whole code

    Refactoring is not perfect but it should be enough for now. If there are no unwanted side effects this would be the last version for the near future.
     
    Last edited: Jan 14, 2017
    Nazgand and sithkazar like this.
  10. sithkazar

    sithkazar Professional Screw Up

    Joined:
    Dec 14, 2015
    Messages:
    750
    Likes Received:
    944
    Reading List:
    Link
    Wow! Thanks for making the manga updates version. For some reason the images are bigger on there... I wonder if they just have larger stored images?
     
    Last edited: Jan 14, 2017
  11. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    Should not matter if the cover images are bigger or smaller. The Images stylesheets first resizes the height to a fix height value (height:400px) and the width accordingly (width:auto). At least that is the intended behaviour.
    Maybe the impression of the images seem bigger since many are narrower or in widescreen format.

    Well since i rechecked there was a need for multiple block images on mangaupdates. Now imageblocker setting can have multiple image urls seperated by a comma.

    release Version 1.2 for both cover previews
    • imageblock setting can have multiple image urls seperated by a comma
     
    runsing, Nazgand and sithkazar like this.
  12. Nazgand

    Nazgand New Member

    Joined:
    Oct 1, 2016
    Messages:
    480
    Likes Received:
    407
    Reading List:
    Link
    @sz I noticed there are warnings when editing the script in tampermonkey. Also, tampermonkey highlights the extraneous whitespace in red, which can be dealt with by using jsbeautify. Some of the warnings are about using !== instead of !=, some are about not declaring functions in blocks. I posted my modification as feedback on greasyfork.
     
  13. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    Code cleaned up. No more warnings in tampermonkey.
    But kept functions as function expression in the if condition (INDIVIDUALPAGETEST). No need for functions if link is not a target serie link.

    Edit:
    @Nazgand,@noisypixy: Nice Code. Gotta see what i can understand and incorporate to optimise my version.
    Up to now i thought that calling all subpages in a short timespan would call some throttle or block to reduce server resources.
    Jquerys Promises() instead of traditional ajax calls seems interesting and are much easier to read.
     
    Last edited: Jan 17, 2017
    Nazgand, sithkazar and Shio like this.
  14. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    Looked at the collaborated cover preview version of @Nazgand and @noisypixy
    Copied getNovelLinks() and tested for a while if getting every subpage link(first time each day) gets one throttled or blocked. Since that does not seem to be the case i updated my code with complete loading of each series page and getting the corresponding image url too.
    To reduce request count i have not activated preloading of images.
    Code needs to be cleaned up but everything seems to be working as intended. Probably last version if novelupdates theme structure is not changing in the near future.

    Released Version 1.3
    https://greasyfork.org/scripts/26439-novelupdates-cover-preview
     
    Nazgand, sithkazar and noisypixy like this.
  15. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    Long time no update. Since i just updated the selectors in
    https://greasyfork.org/scripts/26513-mangaupdates-cover-preview/ to work with the current mangaupdates layout i have also looked if there are some changes to my used userscript addon

    Just released Version 1.3.2
    • now also working on the forum pages (tested with violentmonkey on Firefox and Chrome)

    I have just added the metas for
    // @include https://forum.novelupdates.com/*
    // @include http://forum.novelupdates.com/*
    and added an addional selector ".messageContent a" to SELECTOR1 to make it work on the forum sites.
    Chrome seems to need an additional line
    // @inject-into content
    to make it work cross-site


    Version 1.3.3
    • ".messageContent a" moved to SELECTOR2 type (same vertical position as link instead of top position of table cell)
     
    Last edited: Feb 24, 2019
    sithkazar and Ddraig like this.
  16. terabyte

    terabyte Well-Known Member

    Joined:
    Nov 1, 2017
    Messages:
    32
    Likes Received:
    14
    Reading List:
    Link
    After the recent 1.3.5 update the script doesn't load the preview image anymore for several series, the spinner loading image remains in its place instead.

    Looking in the console a Javascript error is being thrown: "Uncaught ReferenceError: showPopupLoadingSpinner is not defined".

    I've switched to a different cover preview userscript. Here's the link in case someone is having the same issue:
    • github. com/Nazgand/userscripts
     
    runsing likes this.
  17. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    Yes Nazgand one is a nice lean version where small covers are shown besides the links.


    Sorry hat forgotten to change something between dev and release.

    New release Version 1.4.1 which should work again.
    • new spinner animation
    • better positioning
    • if window size available should always show preview images up to 400px width/height
     
  18. terabyte

    terabyte Well-Known Member

    Joined:
    Nov 1, 2017
    Messages:
    32
    Likes Received:
    14
    Reading List:
    Link
    I've updated to 1.4.1 but I'm still getting the same JS error as before and now no series shows the image. Rather, the popup doesn't start showing at all this time:
    Code:
    userscript.html?name=novelupdates%20Cover%20Preview.user.js&id=XXX:445 Uncaught ReferenceError: showPopupLoadingSpinner is not defined
        at Function.onLoad (userscript.html?name=novelupdates%20Cover%20Preview.user.js&id=XXX:445)
        at <anonymous>:3:98
        at eval (eval at exec_fn (VM6036:1), <anonymous>:28:123)
    In case it helps I'm testing on Windows 10, Chrome v86.0.4240.183 (64 bit), Tampermonkey v4.10.
     
  19. sz

    sz Well-Known Member

    Joined:
    Mar 8, 2016
    Messages:
    48
    Likes Received:
    46
    Reading List:
    Link
    Ok i have tested it with violentmonkey. I will try to see why it is not working in tampermonkey.
     
  20. terabyte

    terabyte Well-Known Member

    Joined:
    Nov 1, 2017
    Messages:
    32
    Likes Received:
    14
    Reading List:
    Link
    Thanks for checking. I can give it another try tomorrow if you need help debugging things.