IMSLP - remove notices

Remove the IMSLP contribution ad and disclaimer.

当前为 2016-03-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        IMSLP - remove notices
// @namespace   *
// @description Remove the IMSLP contribution ad and disclaimer.
// @include     http://*imslp.org/*
// @version     .10
// @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("content").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 "";
}