pixiv direct original image link

On page with thumbnails of all works makes thumbnails link to actual fullsize images

  1. // ==UserScript==
  2. // @name pixiv direct original image link
  3. // @namespace pixiv
  4. // @version 1.92
  5. // @description On page with thumbnails of all works makes thumbnails link to actual fullsize images
  6. // @homepage https://greatest.deepsurf.us/ru/scripts/108-pixiv-direct-original-image-link
  7. // @match http://www.pixiv.net/member_illust.php*id*
  8. // @match http://*.pixiv.net/img*
  9. // @run_at document_end
  10. // @run-at document-end
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. if(document.location.hostname != "www.pixiv.net") // manga fix
  15. {
  16. if(document.body.innerHTML.indexOf("This Page is Not Found") == 4 && document.referrer.indexOf("http://www.pixiv.net/member_illust.php?id=") == 0)
  17. {
  18. var newpage = document.location.href.substr(document.location.href.lastIndexOf("/")+1);
  19. newpage = newpage.substring(0, newpage.indexOf('.'));
  20. document.location.replace("http://www.pixiv.net/member_illust.php?mode=manga&illust_id=" + newpage);
  21. }
  22. return false;
  23. }
  24. else if(document.referrer.indexOf("http://www.pixiv.net/") != 0 && document.querySelector("div.errorArea"))
  25. {
  26. var newpage = document.location.href.substr(document.location.href.lastIndexOf("=")+1);
  27. window.history.pushState(null,null,"http://www.pixiv.net/member_illust.php?mode=medium&illust_id=" + newpage); // referrer spoof
  28. document.location.replace("http://www.pixiv.net/member_illust.php?mode=ugoira_view&illust_id=" + newpage);
  29. return false;
  30. }
  31.  
  32. var allImgs, thisImgDiv, src, txt, elmNewContent, profIMG, mangafix = false;
  33.  
  34. profIMG = document.body.querySelector("img.user-image");
  35. if(!profIMG){return false;}
  36. else{profIMG = profIMG.src;}
  37. if(profIMG.indexOf("http://source.pixiv.net") == -1)
  38. {
  39. profIMG = profIMG.substring(0, profIMG.lastIndexOf('/')) + "/";
  40. profIMG = profIMG.replace('profile', 'img');
  41. }
  42. else // no avatar, use BG
  43. {
  44. var fn;
  45. var f = document.getElementsByTagName("style");
  46. for(c=0;c<f.length;c++)
  47. {
  48. fn = f[c].innerHTML.indexOf('url(');
  49. if(fn != -1)
  50. {
  51. profIMG = f[c].innerHTML.substr(fn+5, f[c].innerHTML.indexOf(')', fn+6)-fn-6);
  52. profIMG = profIMG.replace('/profile/', '/img/');
  53. profIMG = profIMG.substring(0, profIMG.lastIndexOf('/')+1);
  54. break;
  55. }
  56. }
  57. }
  58.  
  59. allImgs = document.body.querySelectorAll("img._thumbnail");
  60.  
  61. for (var i = 0; i < allImgs.length; i++)
  62. {
  63. var thisImgDiv = allImgs[i].parentNode;
  64. if(allImgs[i].src.indexOf("_master") != -1) // new
  65. {
  66. if(thisImgDiv.parentNode.className.indexOf(" multiple ") != -1)
  67. {
  68. thisImgDiv.parentNode.href = "http://www.pixiv.net/member_illust.php?mode=manga&illust_id=" + thisImgDiv.parentNode.href.substr(thisImgDiv.parentNode.href.lastIndexOf("=")+1);
  69. }
  70. else
  71. {
  72. var original_image = allImgs[i].src.replace('img-master', 'img-original');
  73. original_image = original_image.replace('c/150x150', '');
  74. original_image = original_image.replace('_master1200', '');
  75. original_image = original_image.replace('t//', 't/');
  76. original_image = original_image.replace('.jpg', '.png');
  77. thisImgDiv.parentNode.href = original_image;
  78. }
  79. }
  80. else // old, still used
  81. {
  82. var number = allImgs[i].src.substr(allImgs[i].src.lastIndexOf("/")+1);
  83. number = number.replace('_s', '');
  84. thisImgDiv.parentNode.href = profIMG + number;
  85. }
  86. thisImgDiv.parentNode.target = "_blank";
  87. }