IMSLP - remove notices

Remove the IMSLP contribution ad and disclaimer.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        IMSLP - remove notices
// @namespace   *
// @description Remove the IMSLP contribution ad and disclaimer.
// @include     http://*imslp.org/*
// @include     https://*imslp.org/*
// @version     .11
// @grant       none
// @run-at      document-end
// ==/UserScript==

// By downloading and installing this script, you acknowledge that each time you 
// use this script you have read, understood and accepted the terms of the IMSLP
// general disclaimer found at
// http://imslp.org/wiki/IMSLP:General_disclaimer .


//
// Replace the contribution ad with a link to the score.
//

// Ensure page is fully loaded.
$(window).load(function(){ 

  // Grab the URL to the score.
  scoreURL = document.getElementById("sm_dl_wait").getAttribute('data-id');

  // Replace the content area with a link to the URL.
  document.getElementById("wiki-body").innerHTML = "<a href=" + scoreURL + " target = '_blank'>Link to score</a>"
  
  // Navigate to score. If this fails, the above link will serve as a backup.
  window.location.href = scoreURL

})

//
// Acknowledge the IMSLP disclaimer.
//

setDisclaimer();

function setDisclaimer()
{
var cookieName = "imslpdisclaimeraccepted";
var cookieValue = "yes";

var currentCookieValue = getCookie(cookieName);
var domain = document.domain.replace (/^www\./, "");
if (currentCookieValue != cookieValue) {
	document.cookie = cookieName + "=" + cookieValue + ";path=/;domain=" + domain + ";expires=;";
	location.reload(true);
	}
}

// Thanks to http://www.w3schools.com/js/js_cookies.asp
function getCookie(cname)
{
var name = cname + "=";
var cookieArr = document.cookie.split(';');
for(var i=0; i<cookieArr.length; i++)
  {
  var c = cookieArr[i].trim();
  if (c.indexOf(name)===0) return c.substring(name.length,c.length);
  }
  return "";
}