Created
November 25, 2013 17:05
-
-
Save anonymous/d493a2e6d08abda47081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name AftenpostenPaywallRemover | |
// @fullname AftenpostenPaywallRemover2000 | |
// @description Aftenposten paywall remover | |
// @author morradi | |
// @version 2013-11-25.2 | |
// @include http://aftenposten.no/* | |
// @include http://*.aftenposten.no/* | |
// ==/UserScript== | |
// init | |
var cookieKeyTargetList = ['VPW_QuotaInfo_', 'VPW_Quota_']; | |
// helpers | |
function MatchCookieKeyAgainstTargetList(key) { | |
for (var i = 0; i < cookieKeyTargetList.length; i++) { | |
if (key.indexOf(cookieKeyTargetList[i]) != -1) { | |
return true; | |
} | |
} | |
return false; | |
} | |
function ExpireCookie(key) { | |
var expireDate = new Date(); | |
expireDate.setSeconds(expireDate.getSeconds()+-1*24*60*60*1000); | |
document.cookie = key + "=;path=/;expires=" + expireDate.toGMTString(); | |
} | |
// runtime | |
function Run() { | |
var cookeeehs = document.cookie; | |
if (cookeeehs === "") { | |
return; | |
} | |
var list = cookeeehs.split("; "); | |
for(var i = 0; i < list.length; i++) { | |
var cookie = list[i]; | |
var p = cookie.indexOf("="); | |
var key = cookie.substring(0,p); | |
if (MatchCookieKeyAgainstTargetList(key)) { | |
ExpireCookie(key); | |
} | |
} | |
} | |
Run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment