Skip to content

Instantly share code, notes, and snippets.

Created November 25, 2013 17:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d493a2e6d08abda47081 to your computer and use it in GitHub Desktop.
Save anonymous/d493a2e6d08abda47081 to your computer and use it in GitHub Desktop.
// ==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