NWCD search link on Discogs

Link to a search from discogs pages to NWCD

  1. // ==UserScript==
  2. // @name NWCD search link on Discogs
  3. // @version 0.65
  4. // @description Link to a search from discogs pages to NWCD
  5. // @author Chameleon
  6. // @include http*://*discogs.com/*
  7. // @include http*://notwhat.cd/upload.php*
  8. // @grant none
  9. // @namespace https://greasyfork.org/users/87476
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. if(window.location.href.indexOf('https://www.discogs.com') != -1)
  15. showDiscogs();
  16. else if(window.location.href.indexOf('notwhat.cd') != -1)
  17. showPTH();
  18.  
  19. })();
  20.  
  21. function showPTH()
  22. {
  23. var discogs=window.location.href.split('discogs=');
  24. if(discogs.length == 1)
  25. return;
  26. discogs=discogs[1];
  27. var yadg_input=document.getElementById('yadg_input');
  28. if(!yadg_input)
  29. {
  30. window.setTimeout(showPTH, 500);
  31. return;
  32. }
  33. yadg_input.value=decodeURIComponent(discogs);
  34. var yadg_target=document.getElementById('yadg_target');
  35. if(window.location.href.indexOf('edition=0') != -1)
  36. {
  37. yadg_target.value="original";
  38. }
  39. else
  40. {
  41. yadg_target.value="other";
  42. }
  43. document.getElementById('yadg_submit').click();
  44. }
  45.  
  46. function showDiscogs()
  47. {
  48. var pTitle=document.getElementById('profile_title');
  49. if(pTitle)
  50. {
  51. var album = pTitle.getElementsByTagName('span');
  52. album=album[album.length-1].textContent.trim();
  53. var span=pTitle.getElementsByTagName('a')[0].parentNode;
  54. var artist=span.getAttribute('title').replace(/\(.*\)/g, '');
  55. var page_aside=document.getElementById('page_aside');
  56. var before=page_aside.firstElementChild.nextElementSibling.nextElementSibling;
  57. var div=document.createElement('div');
  58. div.setAttribute('class', 'section');
  59. before.parentNode.insertBefore(div, before);
  60. var h3=document.createElement('h3');
  61. div.appendChild(h3);
  62. var img=document.createElement('img');
  63. img.src='https://art.notwhat.co/5e795d5cad9e.png';
  64. img.style.height='1em';
  65. h3.appendChild(img);
  66. h3.appendChild(document.createTextNode(' NWCD'));
  67. var d1=document.createElement('div');
  68. d1.setAttribute('class', 'section_content');
  69. div.appendChild(d1);
  70. var a=document.createElement('a');
  71. a.href="https://notwhat.cd/artist.php?artistname="+artist;
  72. a.innerHTML="Search artist";
  73. d1.appendChild(a);
  74. d1.appendChild(document.createElement('br'));
  75. var a=document.createElement('a');
  76. a.href="https://notwhat.cd/torrents.php?searchstr="+encodeURIComponent(artist+' '+album);
  77. a.innerHTML = 'Search album';
  78. d1.appendChild(a);
  79. d1.appendChild(document.createElement('br'));
  80. var a=document.createElement('a');
  81. a.href="https://notwhat.cd/upload.php?edition=0&discogs="+encodeURIComponent(window.location.href);
  82. a.innerHTML = 'Upload original';
  83. d1.appendChild(a);
  84. d1.appendChild(document.createElement('br'));
  85. var a=document.createElement('a');
  86. a.href="https://notwhat.cd/upload.php?discogs="+encodeURIComponent(window.location.href);
  87. a.innerHTML = 'Upload edition';
  88. d1.appendChild(a);
  89. d1.appendChild(document.createElement('br'));
  90. /*var a=document.createElement('a');
  91. a.href="https://notwhat.cd/artist.php?artistname="+artist;
  92. //a.innerHTML = "pth";
  93. var img=document.createElement('img');
  94. img.src='https://art.notwhat.co/5e795d5cad9e.png';
  95. img.style.height='0.8em';
  96. a.appendChild(img);
  97. span.appendChild(document.createTextNode(' '));
  98. span.appendChild(a);
  99. var a=document.createElement('a');
  100. a.href="https://notwhat.cd/torrents.php?searchstr="+encodeURIComponent(artist+' '+album);
  101. //a.innerHTML = "pth";
  102. var img=document.createElement('img');
  103. img.src='https://art.notwhat.co/5e795d5cad9e.png';
  104. img.style.height='0.8em';
  105. a.appendChild(img);
  106. pTitle.appendChild(a);
  107. var a=document.createElement('a');
  108. a.href="https://notwhat.cd/upload.php?discogs="+encodeURIComponent(window.location.href);
  109. //a.innerHTML = "pth";
  110. var img=document.createElement('img');
  111. img.src='https://art.notwhat.co/5e795d5cad9e.png';
  112. a.title='Upload to NWCD (Edition)';
  113. img.style.height='0.8em';
  114. a.appendChild(img);
  115. pTitle.appendChild(document.createTextNode(' '));
  116. pTitle.appendChild(a);
  117. var a=document.createElement('a');
  118. a.href="https://notwhat.cd/upload.php?edition=0&discogs="+encodeURIComponent(window.location.href);
  119. //a.innerHTML = "pth";
  120. var img=document.createElement('img');
  121. img.src='https://art.notwhat.co/5e795d5cad9e.png';
  122. a.title='Upload to NWCD (Original)';
  123. img.style.height='0.8em';
  124. a.appendChild(img);
  125. pTitle.appendChild(document.createTextNode(' '));
  126. pTitle.appendChild(a);*/
  127. }
  128. }