VNDB Cover Preview

Previews covers in vndb.org searches when hovering over the respective hyperlinks.

< Feedback on VNDB Cover Preview

Review: Good - script works

§
Posted: 05.06.2022
Edited: 05.06.2022

(contribution) Reduce the number of requests

Thanks for the useful script.

If you apply the following changes you can prevent the script from requesting resources that it doesn't need.
Uses domparser to parse the dom instead of jquery. Also switched to querySelector which is a nicer way to find the node that you need.

  //....This is around line ~80

  $.ajax({
     url: pagelink,
     dataType: 'text',
     success: function (data) {
        // Convert the HTML string into a document object
        var parser = new DOMParser();
        let dataDOC = parser.parseFromString(data, 'text/html');

       // Grab character image
       if (pagelink.search(CharacterLinkTest) != -1){
           var imagelink = dataDOC.querySelector(".charimg img").src;
       }
       // Grab visual novel cover
       else{
           var imagelink = dataDOC.querySelector(".vnimg img").src;
       }

   //....script continues

Kuro_scriptsAuthor
§
Posted: 05.06.2022

Thanks for the contribution! This is nice. Gonna add it in. :>

Post reply

Sign in to post a reply.