Greasy Fork is available in English.

RED : Streaming Search Links

Adds Spotify, Deezer or Tidal search links on RED

  1. // ==UserScript==
  2. // @name RED : Streaming Search Links
  3. // @description Adds Spotify, Deezer or Tidal search links on RED
  4. // @author Quoph
  5. // @version 1.3.10
  6. // @include http*://redacted.ch/*
  7. // @include http*://*orpheus.network/*
  8. // @include http*://notwhat.cd/*
  9. // @grant none
  10. // @namespace https://greasyfork.org/users/165243
  11. // ==/UserScript==
  12. //
  13. // Quoph's non-API version, credits to orkyl, aphex80, spacepandas and duskyliability for the original Spotify Integration script.
  14. //
  15. // CHANGELOG
  16. // 1.3.10 14/12/2019
  17. // fix: Improved forum post link translation
  18. //
  19. // 1.3.9 8/11/2019
  20. // add: Include new Orpheus URL
  21. // add: Album and Artist search strings for Spotify and Tidal web searches
  22. //
  23. // 1.3.8 20/10/2019
  24. // fix: Spotify web search url
  25. //
  26. // 1.3.7 28/06/2019
  27. // add: Links added to official forum post torrent links
  28. // fix: Reconfigured Tidal search urls as generic searches
  29. //
  30. // 1.3.6 30/03/2018
  31. // add: Links added to bookmarked requests & requests on user pages
  32. // fix: Don't display links if no requests found
  33. // fix: Generate links for Various Artist releases on collages and bookmarks page
  34. //
  35. // 1.3.5 05/03/2018
  36. // add: Links added requests.php
  37. // add: Links added to compositions and requests sections on Artist pages
  38. //
  39. // 1.3.4 12/02/2018
  40. // add: Script settings added to user settings page to allow changes from APL and NWCD
  41. // fix: General code tidying
  42. // fix: Only run (get settings) on pages with links
  43. //
  44. // 1.3.3 11/02/2018
  45. // add: Transfer settings from RED to APL and NWCD
  46. //
  47. // 1.3.2 11/02/2018
  48. // fix: No blank tabs when opening Spotify app
  49. //
  50. // 1.3.1 11/02/2018
  51. // add: User preferences placed on forum thread
  52. // to do: APL & NWCD user settings solution
  53. // add: (Artist page) Links generated on Singles, Live Albums, Anthologies, Remixes, Mixtapes,
  54. // Appearances, Produced Bys, Mixed Bys and Compilations
  55. // fix: Consolidated link creation with functions (DRY)
  56. // change: Name changed to Streaming Search Links to reflect the additional streaming services
  57. //
  58. // 1.2.1 04/02/2018
  59. // add: Tidal links
  60. //
  61. // 1.2 02/01/2018
  62. // add: Deezer Links
  63. // add: Support for more trackers: APL and NWCD.
  64. // add: Support for secure and non-secure domain URLs.
  65. // change: Moved from pastebin to Greasy Fork.
  66.  
  67. var settings = getSettings();
  68.  
  69. if (window.location.href.indexOf('threadid=17119') > -1 || window.location.href.indexOf('user.php?action=edit') > -1) {
  70. showSettings();
  71. }
  72.  
  73. function showSettings() {
  74. var div = document.getElementById('SSLSettings');
  75. var userSettings = window.location.href.indexOf('user.php?action=edit') > -1;
  76. if (userSettings && !div) {
  77. div = document.createElement('table');
  78. div.setAttribute('id', 'SSLSettings');
  79. $(".main_column").append(div);
  80. }
  81. if(window.location.href.indexOf('threadid=17119') > -1 && !div) {
  82. var before = document.getElementsByClassName('forum_post')[0];
  83. div = document.createElement('div');
  84. div.setAttribute('id', 'SSLSettings');
  85. before.parentNode.insertBefore(div, before);
  86. div.setAttribute('style', 'width: 100%; text-align: center;');
  87. div.setAttribute('class', 'box');
  88. }
  89. div.innerHTML = (userSettings ? '<tbody><tr class="colhead_dark"><td colspan="2"><strong>Streaming Search Links Settings</strong></td></tr><tr><td>' : '<h2>Streaming Search Links Settings</h2><br />') + '<span>Deezer</span><span>Tidal</span><span>Spotify</span><span>Spotify Player: </span>' + (userSettings ? '</td></tr></tbody>' : '');
  90. var settings = getSettings();
  91. var span = div.getElementsByTagName('span');
  92. function createCheckbox (name, setting, mySpan) {
  93. var checkbox=document.createElement('input');
  94. checkbox.type = 'checkbox';
  95. checkbox.setAttribute("name", name);
  96. checkbox.setAttribute('style', 'margin: 0 10px;');
  97. checkbox.checked = setting ? setting:'';
  98. checkbox.addEventListener('change', changeSettings.bind(undefined, checkbox, div, undefined), false);
  99. mySpan.appendChild(checkbox);
  100. }
  101. createCheckbox ("Deezer", settings.Deezer, span[0]);
  102. createCheckbox ("Tidal", settings.Tidal, span[1]);
  103. createCheckbox ("Spotify", settings.Spotify, span[2]);
  104. var select=document.createElement('select');
  105. var op = new Option();
  106. op.text = "APP";
  107. var op2 = new Option();
  108. op2.text = "WEB";
  109. select.options.add(op);
  110. select.options.add(op2);
  111. select.selectedIndex = (settings.spotifyApp ? 0 : 1);
  112. select.addEventListener('change', changeSettings.bind(undefined, select, div, select.selectedIndex), false);
  113. span[3].appendChild(select);
  114. div.appendChild(document.createElement('br'));
  115. }
  116.  
  117. function changeSettings(obj, div, val) {
  118. var settings = getSettings();
  119. var x = div.getElementsByTagName('input');
  120. var sel = div.getElementsByTagName('select');
  121. if (obj == x[0]) {
  122. if(x[0].checked) {
  123. settings.Deezer = true;
  124. } else
  125. settings.Deezer = false;
  126. }
  127. if (obj == x[2]) {
  128. if(x[2].checked) {
  129. settings.Spotify = true;
  130. } else
  131. settings.Spotify = false;
  132. }
  133. if (obj == x[1]) {
  134. if(x[1].checked) {
  135. settings.Tidal = true;
  136. } else
  137. settings.Tidal = false;
  138. }
  139. if (obj == sel[0]) {
  140. if(val !== 1) {
  141. settings.spotifyApp = false;
  142. } else
  143. settings.spotifyApp = true;
  144. }
  145. window.localStorage.spotifySearchLinksSettings = JSON.stringify(settings);
  146. showSettings();
  147. }
  148.  
  149. function getSettings() {
  150. var settings = window.localStorage.spotifySearchLinksSettings;
  151. if (!settings) {
  152. settings = {Deezer:false, Spotify:true, Tidal:false, spotifyApp:true};
  153. } else
  154. settings = JSON.parse(settings);
  155. if (settings.spotifyApp) {
  156. spotURL = 'spotify:search:';
  157. } else {
  158. spotURL = 'https://open.spotify.com/search/';
  159. }
  160. return settings;
  161. }
  162.  
  163. var deezURL = 'http://www.deezer.com/search/';
  164. var tidURL = 'https://listen.tidal.com/search/';
  165. var SpotAlb = settings.spotifyApp ? '' : "/albums";
  166. var SpotArt = settings.spotifyApp ? '' : "/artists";
  167. var deezIMG = ['Listen on Deezer','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IAr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g=='];
  170. var d, s, t, links, spotURL;
  171.  
  172. function linkSetting() {
  173. var settings = getSettings();
  174. var linksArray = [];
  175. if (settings.Deezer) {linksArray.push(d);}
  176. if (settings.Spotify) {linksArray.push(s);}
  177. if (settings.Tidal) {linksArray.push(t);}
  178. links = linksArray;
  179. return links;
  180. }
  181. function createLink(link, linkData) {
  182. var a = document.createElement('a');
  183. a.href = link;
  184. if (link.indexOf('spotify:search:') === -1) {
  185. a.setAttribute('target', '_blank'); }
  186. a.title = linkData[0];
  187. var img = document.createElement('img');
  188. img.style.border = 'none';
  189. img.style.marginLeft = '3px';
  190. img.style.marginRight = '3px';
  191. img.style.position = "relative";
  192. img.style.top = '2px';
  193. img.src = linkData[1];
  194. img.width = 14;
  195. a.appendChild(img);
  196. return a;
  197. }
  198. function createLinks (whatArtist, whatAlbum) {
  199. d = createLink(deezURL + encodeURIComponent(whatArtist) + "%20" + encodeURIComponent(whatAlbum) + "/album", deezIMG);
  200. s = createLink(spotURL + encodeURIComponent(whatArtist) + "%20" + encodeURIComponent(whatAlbum) + SpotAlb, spotIMG);
  201. t = createLink(tidURL + "albums?q=" + encodeURIComponent(whatArtist) + "%20" + encodeURIComponent(whatAlbum), tidIMG);
  202. linkSetting();
  203. }
  204. function createArtistLinks (whatArtist) {
  205. d = createLink(deezURL + encodeURIComponent(whatArtist) + "/artist", deezIMG);
  206. s = createLink(spotURL + encodeURIComponent(whatArtist) + SpotArt, spotIMG);
  207. t = createLink(tidURL + "artists?q=" + encodeURIComponent(whatArtist), tidIMG);
  208. linkSetting();
  209. }
  210. /*****************************************/
  211. /** Top 10 / Collage Updates / Torrents **/
  212. /*****************************************/
  213. if (window.location.href.indexOf('top10.php') > -1 || window.location.href.indexOf('userhistory.php') > -1 || window.location.href.indexOf('torrents.php') > -1) {
  214. var groups = $('div.group_info');
  215. $(groups).each(function(i, group) {
  216. var myArtist = $(group).find('a[href*="artist.php"]')[0];
  217. var myAlbum = $(group).find('a[href*="torrents.php?id"]')[0];
  218. createLinks($(myArtist).text(), $(myAlbum).text());
  219. $(group).prepend(links);
  220. });
  221. }
  222. /*************************************/
  223. /** Collage & Bookmark torrent page **/
  224. /*************************************/
  225. if (window.location.href.indexOf('collages.php') > -1 || window.location.href.indexOf('collage.php?id') > -1 || window.location.href.indexOf('bookmarks.php?type=torrents') > -1) {
  226. var groups = $('.group');
  227. $(groups).each(function(i, group) {
  228. var whatArtistElement = $(group).find('a[href*="artist.php"]')[0];
  229. var whatAlbumElement = $(group).find('a[href*="torrents.php?id"]')[0];
  230. createLinks($(whatArtistElement).text(), $(whatAlbumElement).text());
  231. if (typeof whatArtistElement == "undefined") {
  232. $(whatAlbumElement).before(links);}
  233. else {
  234. $(whatArtistElement).before(links);}
  235. });
  236. }
  237. /*************************************/
  238. /*********** Artist page *************/
  239. /*************************************/
  240. if (window.location.href.indexOf('artist.php') > -1) {
  241. createArtistLinks($('h2').first().text());
  242. {$('h2').append(links);}
  243. var groups = $('#torrents_album, #torrents_ep, #torrents_anthology, #torrents_single, #torrents_live_album, #torrents_remix, #torrents_mixtape').find('div.group_info');
  244. var groups2 = $('#torrents_guest_appearance, #torrents_produced_by, #torrents_remixed_by, #torrents_compilation, #torrents_composition').find('div.group_info');
  245. $(groups).each(function (i, group) {
  246. whatAlbum = $(group).find('a[href*="torrents.php?id"]')[0];
  247. createLinks($('h2').first().text(), $(whatAlbum).text());
  248. $(group).prepend(links);
  249. });
  250. $(groups2).each(function (i, group) {
  251. whatArtistElement = $(group).find('a[href*="artist.php"]')[0];
  252. whatAlbum = $(group).find('a[href*="torrents.php?id"]')[0];
  253. createLinks($(whatArtistElement).text(), $(whatAlbum).text());
  254. $(group).prepend(links);
  255. });
  256. }
  257. /*************************************/
  258. /*********** Torrent page ************/
  259. /*************************************/
  260. if (window.location.href.indexOf('torrents.php?id') > -1) {
  261. createLinks($('h2 > a').first().text(), $('h2 > span').text());
  262. $('h2').append(links);
  263. }
  264. /*************************************/
  265. /******* Bookmark artist page ********/
  266. /*************************************/
  267. if (window.location.href.indexOf('bookmarks.php?type=artists') > -1) {
  268. var tds = $('.artist_table').find('.rowa, .rowb').find('td');
  269. var artists = $('.artist_table').find('a[href*="artist.php?id"]');
  270. $(artists).each(function(i, artistElement) {
  271. createArtistLinks($(artistElement).text());
  272. $(tds[i]).prepend(links);
  273. });
  274. }
  275. /*************************************/
  276. /************* Requests **************/
  277. /*************************************/
  278. if (window.location.href.indexOf('requests.php') > -1 || window.location.href.indexOf('bookmarks.php?type=requests') > -1 || window.location.href.indexOf('user.php?id=') > -1 || window.location.href.indexOf('artist.php') > -1) {
  279. var tds = $('.request_table').find('.rowa, .rowb').find('td:first');
  280. $(tds).each(function(i, group) {
  281. var whatArtist = $(group).find('a[href*="artist.php?id"]')[0];
  282. var whatAlbum = $(group).find('a[href*="requests.php?action=view&id"]')[0];
  283. if (typeof whatAlbum != "undefined") {
  284. createLinks($(whatArtist).text(), $(whatAlbum).text().slice(0, -7));
  285. $(group).prepend(links);
  286. }
  287. });
  288. }
  289. /*************************************/
  290. /*********** Request page ************/
  291. /*************************************/
  292. if (window.location.href.indexOf('requests.php?action=view&id') > -1) {
  293. var whatArtist = $('h2').find('a[href*="artist.php?id"]')[0];
  294. var whatAlbum = $('h2').find('a[href*="torrents.php?torrentid"]')[0];
  295. createLinks($(whatArtist).text(), $(whatAlbum).length ? $(whatAlbum).text() : $('h2 > span').text());
  296. $('h2').append(links);
  297. }
  298. /*************************************/
  299. /*********** Forum Posts *************/
  300. /*************************************/
  301. var post = $('.forum_post .body');
  302. $(post).each(function(i, b){
  303. var as = $(this).find('a');
  304. $(as).each(function() {
  305. if (this.href.indexOf('torrents.php?id=') > -1 || this.href.indexOf('bandcamp.com/album/') > -1 ){
  306. var [thisArtist, thisAlbum] = $(this).text().split(" - ");
  307. if (typeof thisAlbum != "undefined") {
  308. var year = thisAlbum.search(/\s\(\d{4}\)/);
  309. if (year > -1 ) {
  310. createLinks((thisArtist), (thisAlbum).slice(0, year));}
  311. else {
  312. createLinks((thisArtist), (thisAlbum));}
  313. $(this).prepend(links);
  314. }
  315. }});
  316. });