IMSLP - remove notices

Remove the IMSLP contribution ad and disclaimer.

  1. // ==UserScript==
  2. // @name IMSLP - remove notices
  3. // @namespace *
  4. // @description Remove the IMSLP contribution ad and disclaimer.
  5. // @include http://*imslp.org/*
  6. // @include https://*imslp.org/*
  7. // @version .11
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. // By downloading and installing this script, you acknowledge that each time you
  13. // use this script you have read, understood and accepted the terms of the IMSLP
  14. // general disclaimer found at
  15. // http://imslp.org/wiki/IMSLP:General_disclaimer .
  16.  
  17.  
  18. //
  19. // Replace the contribution ad with a link to the score.
  20. //
  21.  
  22. // Ensure page is fully loaded.
  23. $(window).load(function(){
  24.  
  25. // Grab the URL to the score.
  26. scoreURL = document.getElementById("sm_dl_wait").getAttribute('data-id');
  27.  
  28. // Replace the content area with a link to the URL.
  29. document.getElementById("wiki-body").innerHTML = "<a href=" + scoreURL + " target = '_blank'>Link to score</a>"
  30. // Navigate to score. If this fails, the above link will serve as a backup.
  31. window.location.href = scoreURL
  32.  
  33. })
  34.  
  35. //
  36. // Acknowledge the IMSLP disclaimer.
  37. //
  38.  
  39. setDisclaimer();
  40.  
  41. function setDisclaimer()
  42. {
  43. var cookieName = "imslpdisclaimeraccepted";
  44. var cookieValue = "yes";
  45.  
  46. var currentCookieValue = getCookie(cookieName);
  47. var domain = document.domain.replace (/^www\./, "");
  48. if (currentCookieValue != cookieValue) {
  49. document.cookie = cookieName + "=" + cookieValue + ";path=/;domain=" + domain + ";expires=;";
  50. location.reload(true);
  51. }
  52. }
  53.  
  54. // Thanks to http://www.w3schools.com/js/js_cookies.asp
  55. function getCookie(cname)
  56. {
  57. var name = cname + "=";
  58. var cookieArr = document.cookie.split(';');
  59. for(var i=0; i<cookieArr.length; i++)
  60. {
  61. var c = cookieArr[i].trim();
  62. if (c.indexOf(name)===0) return c.substring(name.length,c.length);
  63. }
  64. return "";
  65. }