VNDB Cover Preview

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

< 腳本VNDB Cover Preview的回應

評論:正評 - 腳本一切正常

§
發表於:2022-06-05
編輯:2022-06-05

(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_scripts作者
§
發表於:2022-06-05

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

發表回覆

登入以回覆