clear_Tieba_in_localStorage

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

As of 2014-07-29. See the latest version.

// ==UserScript==
// @name           clear_Tieba_in_localStorage
// @description    定时清除贴吧留在localStorage中的垃圾
// @include        http://tieba.baidu.com/*
// @author         congxz6688
// @version        2014.7.29.0
// @grant          none
// @namespace https://greasyfork.org/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();
}