RED search link on discogs

Link to a search from discogs pages to RED

  1. // ==UserScript==
  2. // @name RED search link on discogs
  3. // @version 0.7
  4. // @description Link to a search from discogs pages to RED
  5. // @author Chameleon
  6. // @include http*://*discogs.com/*
  7. // @include http*://redacted.ch/upload.php*
  8. // @include http*://redacted.ch/requests.php?action=new*
  9. // @grant none
  10. // @namespace https://gf.qytechs.cn/users/87476
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. if(window.location.href.indexOf('https://www.discogs.com') != -1)
  16. showDiscogs();
  17. else if(window.location.href.indexOf('redacted.ch') != -1)
  18. showPTH();
  19.  
  20. })();
  21.  
  22. function showPTH()
  23. {
  24. var discogs=window.location.href.split('discogs=');
  25. if(discogs.length == 1)
  26. return;
  27. discogs=discogs[1];
  28.  
  29. if(window.location.href.indexOf('requests.php')!==-1)
  30. {
  31. var artist=decodeURIComponent(window.location.search.split('&artist=')[1].split('&')[0]);
  32. var album=decodeURIComponent(window.location.search.split('&album=')[1].split('&')[0]);
  33. var year=decodeURIComponent(window.location.search.split('&year=')[1].split('&')[0]);
  34. document.getElementById('artist').value=artist;
  35. document.getElementsByName('title')[0].value=album;
  36. document.getElementsByName('year')[0].value=year;
  37. return;
  38. }
  39.  
  40. var yadg_input=document.getElementById('yadg_input');
  41. if(!yadg_input)
  42. {
  43. window.setTimeout(showPTH, 500);
  44. return;
  45. }
  46. yadg_input.value=decodeURIComponent(discogs);
  47. var yadg_target=document.getElementById('yadg_target');
  48. if(window.location.href.indexOf('edition=0') != -1)
  49. {
  50. yadg_target.value="original";
  51. }
  52. else
  53. {
  54. yadg_target.value="other";
  55. }
  56. document.getElementById('yadg_submit').click();
  57. }
  58.  
  59. function showDiscogs()
  60. {
  61. var pTitle=document.getElementById('profile_title');
  62. if(pTitle)
  63. {
  64. var albumNodes = pTitle.childNodes;
  65. var album=albumNodes[albumNodes.length-1].textContent.trim();
  66. if(album==="")
  67. album=albumNodes[albumNodes.length-2].textContent.trim();
  68. var span=pTitle.getElementsByTagName('a')[0].parentNode;
  69. var artist=span.getAttribute('title').replace(/\(.*\)/g, '');
  70. var page_aside=document.getElementById('page_aside');
  71. var before=page_aside.firstElementChild.nextElementSibling.nextElementSibling;
  72. var div=document.createElement('div');
  73. div.setAttribute('class', 'section');
  74. before.parentNode.insertBefore(div, before);
  75. var h3=document.createElement('h3');
  76. div.appendChild(h3);
  77. var img=document.createElement('img');
  78. img.src='https://ptpimg.me/2rwc77.png';
  79. img.style.height='1em';
  80. h3.appendChild(img);
  81. h3.appendChild(document.createTextNode(' RED'));
  82. var d1=document.createElement('div');
  83. d1.setAttribute('class', 'section_content');
  84. div.appendChild(d1);
  85. var a=document.createElement('a');
  86. a.href="https://redacted.ch/artist.php?artistname="+artist;
  87. a.innerHTML="Search artist";
  88. d1.appendChild(a);
  89. d1.appendChild(document.createElement('br'));
  90. var a=document.createElement('a');
  91. a.href="https://redacted.ch/torrents.php?searchstr="+encodeURIComponent(artist+' '+album);
  92. a.innerHTML = 'Search album';
  93. d1.appendChild(a);
  94. d1.appendChild(document.createElement('br'));
  95. var a=document.createElement('a');
  96. a.href="https://redacted.ch/upload.php?edition=0&discogs="+encodeURIComponent(window.location.href);
  97. a.innerHTML = 'Upload original';
  98. d1.appendChild(a);
  99. d1.appendChild(document.createElement('br'));
  100.  
  101. var a=document.createElement('a');
  102. a.href="https://redacted.ch/upload.php?discogs="+encodeURIComponent(window.location.href);
  103. a.innerHTML = 'Upload edition';
  104. d1.appendChild(a);
  105. d1.appendChild(document.createElement('br'));
  106.  
  107. var year=document.getElementsByClassName('head');
  108. for(var i=0; i<year.length; i++)
  109. {
  110. if(year[i].innerHTML.indexOf('Released')!==-1)
  111. {
  112. year=year[i].nextElementSibling.textContent.trim().split(' ');
  113. year=year[year.length-1];
  114. break;
  115. }
  116. }
  117. var a=document.createElement('a');
  118. a.href="https://redacted.ch/requests.php?action=new&discogs="+encodeURIComponent(window.location.href)+'&artist='+encodeURIComponent(artist)+'&album='+encodeURIComponent(album)+'&year='+year;
  119. a.innerHTML = 'Request';
  120. d1.appendChild(a);
  121. d1.appendChild(document.createElement('br'));
  122. /*var a=document.createElement('a');
  123. a.href="https://redacted.ch/artist.php?artistname="+artist;
  124. //a.innerHTML = "pth";
  125. var img=document.createElement('img');
  126. img.src='https://ptpimg.me/2rwc77.png';
  127. img.style.height='0.8em';
  128. a.appendChild(img);
  129. span.appendChild(document.createTextNode(' '));
  130. span.appendChild(a);
  131. var a=document.createElement('a');
  132. a.href="https://redacted.ch/torrents.php?searchstr="+encodeURIComponent(artist+' '+album);
  133. //a.innerHTML = "pth";
  134. var img=document.createElement('img');
  135. img.src='https://ptpimg.me/2rwc77.png';
  136. img.style.height='0.8em';
  137. a.appendChild(img);
  138. pTitle.appendChild(a);
  139. var a=document.createElement('a');
  140. a.href="https://redacted.ch/upload.php?discogs="+encodeURIComponent(window.location.href);
  141. //a.innerHTML = "pth";
  142. var img=document.createElement('img');
  143. img.src='https://ptpimg.me/83k157.png';
  144. a.title='Upload to PTH (Edition)';
  145. img.style.height='0.8em';
  146. a.appendChild(img);
  147. pTitle.appendChild(document.createTextNode(' '));
  148. pTitle.appendChild(a);
  149. var a=document.createElement('a');
  150. a.href="https://redacted.ch/upload.php?edition=0&discogs="+encodeURIComponent(window.location.href);
  151. //a.innerHTML = "pth";
  152. var img=document.createElement('img');
  153. img.src='https://ptpimg.me/83k157.png';
  154. a.title='Upload to PTH (Original)';
  155. img.style.height='0.8em';
  156. a.appendChild(img);
  157. pTitle.appendChild(document.createTextNode(' '));
  158. pTitle.appendChild(a);*/
  159. }
  160. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址