您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
当前为
// ==UserScript== // @name History // @namespace http://github.com/kba // @version 0.1 // @description try to take over the world! // @author kba // @match */* // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_getResourceText // @grant GM_registerMenuCommand // @require https://code.jquery.com/jquery-2.2.3.min.js // @require https://code.jquery.com/ui/1.11.4/jquery-ui.min.js // @resource jquery_ui_theme https://code.jquery.com/ui/1.11.4/themes/start/jquery-ui.css // ==/UserScript== /*jshint esversion: 6 */ /*global window */ /*global $ */ /*global GM_registerMenuCommand */ /*global GM_addStyle */ /*global GM_getResourceText */ /*global GM_setValue */ /*global GM_getValue */ var DIALOG_ID = 'gm-history-dialog'; function getCurrentHistoryName() { return GM_getValue("current", "default"); } function setCurrentHistoryName(name) { return GM_setValue("current", name); } function loadHistory() { // return {}; return JSON.parse(GM_getValue("history_" + getCurrentHistoryName(), "{}")); } function saveHistory(hist) { var name = getCurrentHistoryName(); return GM_setValue("history_" + name, JSON.stringify(hist)); } function cleanURL(url) { if (url.substring(0, 1) === '/') { url = window.location.protocol + "//" + window.location.host + url; } return url.replace(/#.*$/, "").toLowerCase(); } function addHistory(url, hist) { if (!hist) { hist = loadHistory(); } hist[cleanURL(url)] = new Date(); saveHistory(hist); } /* * Public API */ function afterPageLoad() { var hist = loadHistory(); addHistory(window.location.href, hist); markVisited(); } function markVisited() { var hist = loadHistory(); $("a[href]").each(function() { var $a = $(this); var linkUrl = cleanURL($a.attr("href")); console.log(linkUrl, hist[linkUrl]); if (hist[linkUrl]) { $a.addClass("gm-history-visited"); } }); } function openDialog() { var hist = loadHistory(); var asText = ""; for (var url in hist) { asText += hist[url] + " :: " + url + "\n"; } $(`#${DIALOG_ID} textarea`).html(asText); $(`#${DIALOG_ID}`).dialog("open"); } function addDialog() { $( ` <div id="${DIALOG_ID}" title="Config GM History"> <div> <h3>Current History</h3> <input placeholder='${getCurrentHistoryName()}' type='text'></input> </div> <div> <h3>Edit History</h3> <textarea rows=10></textarea> </div> </div> ` ).appendTo('body') .dialog({ autoOpen: false, modal: true, resizable: true, height: 300, width: "95vw", buttons: { "Save": function() { var hist = {}; var lines = $(`#${DIALOG_ID} textarea`).val().split(/\n/); for (var i = 0; i < lines.length ; i++) { var line = lines[i].split(/\s*::\s*/); hist[line[1]] = line[0]; } saveHistory(hist); $(this).dialog("close"); } } }); } function promptName() { var newName = window.prompt("New history name? [Current: " + getCurrentHistoryName() + "]"); if (newName) { setCurrentHistoryName(newName); } } function toggleBlurVisited() { markVisited(); $(".gm-history-visited").toggleClass('gm-history-blurred'); } (function() { "use strict"; GM_addStyle(GM_getResourceText("jquery_ui_theme")); GM_addStyle( ` .gm-history-blurred, .gm-history-blurred * { opacity: 0.2 !important } #${DIALOG_ID} { overflow-y: scroll; max-height: 100%; } #${DIALOG_ID} h3 { width: 20%; float: left; } #${DIALOG_ID} h3 + * { width: 75%; float:right; } #${DIALOG_ID} div { clear: left; } `); afterPageLoad(); addDialog(); GM_registerMenuCommand("Configure History", openDialog, "f"); GM_registerMenuCommand("Blur visited", toggleBlurVisited, "b"); }()); // vim: sw=4 noet :
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址