Rapidgator link checker

jlibrary link checker

  1. // ==UserScript==
  2. // @name Rapidgator link checker
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-07-12
  5. // @description jlibrary link checker
  6. // @author ange
  7. // @match https://www.javlibrary.com/en/?v=*
  8. // @match https://www.javlibrary.com/en/videocomments.php?v=*
  9. // @match https://www.javlibrary.com/en/videocomments.php?mode=*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=javlibrary.com
  11. // @grant GM_xmlhttpRequest
  12. // ==/UserScript==
  13.  
  14. const greenTick = `
  15. <svg style="width:14px;height:14px;padding-left:0.25rem;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" enable-background="new 0 0 64 64">
  16. <path d="M32,2C15.431,2,2,15.432,2,32c0,16.568,13.432,30,30,30c16.568,0,30-13.432,30-30C62,15.432,48.568,2,32,2z M25.025,50 l-0.02-0.02L24.988,50L11,35.6l7.029-7.164l6.977,7.184l21-21.619L53,21.199L25.025,50z" fill="#43a047" />
  17. </svg>
  18. `;
  19.  
  20. const redX = `
  21. <svg style="width:14px;height:14px;padding-left:0.25rem;" xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" viewBox="0 0 48 48" version="1.1" id="svg15" sodipodi:docname="cross red circle.svg" inkscape:version="0.92.3 (2405546, 2018-03-11)">
  22. <metadata id="metadata19">
  23. <rdf:RDF>
  24. <cc:Work rdf:about="">
  25. <dc:format>image/svg+xml</dc:format>
  26. <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
  27. <dc:title />
  28. </cc:Work>
  29. </rdf:RDF>
  30. </metadata>
  31. <sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="1920" inkscape:window-height="1027" id="namedview17" showgrid="false" inkscape:zoom="4.9166667" inkscape:cx="-11.694915" inkscape:cy="40.271186" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" inkscape:current-layer="g13" />
  32. <defs id="defs7">
  33. <linearGradient id="linearGradient828" osb:paint="solid">
  34. <stop style="stop-color:#ff0000;stop-opacity:1;" offset="0" id="stop826" />
  35. </linearGradient>
  36. <linearGradient id="0" gradientUnits="userSpaceOnUse" y1="47.37" x2="0" y2="-1.429">
  37. <stop stop-color="#c52828" id="stop2" />
  38. <stop offset="1" stop-color="#ff5454" id="stop4" />
  39. </linearGradient>
  40. </defs>
  41. <g transform="matrix(.99999 0 0 .99999-58.37.882)" enable-background="new" id="g13" style="fill-opacity:1">
  42. <circle cx="82.37" cy="23.12" r="24" fill="url(#0)" id="circle9" style="fill-opacity:1;fill:#dd3333" />
  43. <path d="m87.77 23.725l5.939-5.939c.377-.372.566-.835.566-1.373 0-.54-.189-.997-.566-1.374l-2.747-2.747c-.377-.372-.835-.564-1.373-.564-.539 0-.997.186-1.374.564l-5.939 5.939-5.939-5.939c-.377-.372-.835-.564-1.374-.564-.539 0-.997.186-1.374.564l-2.748 2.747c-.377.378-.566.835-.566 1.374 0 .54.188.997.566 1.373l5.939 5.939-5.939 5.94c-.377.372-.566.835-.566 1.373 0 .54.188.997.566 1.373l2.748 2.747c.377.378.835.564 1.374.564.539 0 .997-.186 1.374-.564l5.939-5.939 5.94 5.939c.377.378.835.564 1.374.564.539 0 .997-.186 1.373-.564l2.747-2.747c.377-.372.566-.835.566-1.373 0-.54-.188-.997-.566-1.373l-5.939-5.94" fill="#fff" fill-opacity=".842" id="path11" style="fill-opacity:1;fill:#ffffff" />
  44. </g>
  45. </svg>
  46. `;
  47.  
  48. const fetchResponse = (url, options = {}) => {
  49. const requestOptions = {
  50. headers: {
  51. "Cache-Control": "no-cache",
  52. },
  53. ...options,
  54. url,
  55. method: options.method || 'GET',
  56. responseType: options.responseType || 'document',
  57. };
  58.  
  59. if (options.data) requestOptions.data = options.data;
  60.  
  61. return new Promise((resolve, reject) => {
  62. GM_xmlhttpRequest({
  63. ...requestOptions,
  64. onload: res => resolve(res),
  65. onerror: err => reject(err),
  66. });
  67. });
  68. };
  69.  
  70. const initRedirectRemoval = () => document.querySelectorAll('a[href^="redirect.php"]').forEach(link => {
  71.  
  72. link.href = decodeURIComponent(link.href.split('=')[1]);
  73. });
  74.  
  75. const checkLinks = () => {
  76. document.querySelectorAll('a[href*="rapidgator"]').forEach(async link => {
  77. const response = await fetchResponse(link, { method:'HEAD' });
  78. const isOk = response.status < 400 && response.finalUrl !== 'https://rapidgator.net/article/premium';
  79. link.innerHTML += isOk ? greenTick: redX;
  80. if (!isOk) link.style = "text-decoration: line-through;display: inline-flex"
  81. });
  82. };
  83.  
  84. initRedirectRemoval();
  85. checkLinks();