clear_Tieba_in_localStorage

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

目前為 2014-07-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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();
}