clear_Tieba_in_localStorage

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

اعتبارا من 29-07-2014. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل 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();
}