fix insert classical works

fix inserting works into tracklist when work has apostrophe in title

  1. // ==UserScript==
  2. // @name fix insert classical works
  3. // @namespace https://greasyfork.org/users/2653
  4. // @version 0.2
  5. // @description fix inserting works into tracklist when work has apostrophe in title
  6. // @author thought_house
  7. // @match https://rateyourmusic.com/releases/ac*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var searchFrame = document.getElementById("shortcutsearchframe");
  15.  
  16. searchFrame.onload = function() {
  17.  
  18. var infoboxes = document.getElementById("shortcutsearchframe").contentDocument.getElementsByClassName("infobox");
  19.  
  20. for (var i = 0; i < infoboxes.length; i++) {
  21. var infobox = infoboxes[i];
  22. var workTitle = infobox.getElementsByClassName('infobox_title')[0].innerHTML;
  23.  
  24. if (workTitle.indexOf("'") >= 0) {
  25. if (infobox.getAttribute('class').indexOf('child') >= 0) {
  26. workTitle = workTitle.replace(/^\d+\. /, '');
  27. }
  28.  
  29. var onclickcode = infobox.children[0].children[0].getAttribute('onclick');
  30. onclickcode = onclickcode.replace(workTitle, workTitle.replace(/'/g, "\\'"));
  31. infobox.children[0].children[0].setAttribute('onclick', onclickcode);
  32. }
  33. }
  34. }
  35. })();