clear_Tieba_in_localStorage

定时清除贴吧留在localStorage中的垃圾

29.07.2014 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name           clear_Tieba_in_localStorage
// @description    定时清除贴吧留在localStorage中的垃圾
// @include        http://tieba.baidu.com/*
// @author         congxz6688
// @version        2014.7.29.0
// @grant          none
// @namespace https://greatest.deepsurf.us/users/39
// ==/UserScript==

var edd = [];
var lastRun = localStorage.lastClearLS ? localStorage.lastClearLS : 0;
var nt = new Date();
var nowTime = nt.getTime();
if (nowTime - lastRun > 604800000) { //这里的604800000是7天的毫秒数,表示脚本运行的间隔,用户可自己修改
	for (i = 0; i < localStorage.length; i++) {
		s = edd.push(localStorage.key(i));
	}
	edd.forEach(function (e) {
		if (e.indexOf("draft") == 0) {
			localStorage.removeItem(e);
		}
	});
	localStorage.lastClearLS = nt.getTime();
}