您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Prefetch links that were hovered for several milliseconds
当前为
// ==UserScript== // @name Prefetch links when hovered // @description Prefetch links that were hovered for several milliseconds // @author Anon // @version 0.1.0 // @license Public domain // @include * // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js // @grant GM_xmlhttpRequest // @grant GM_log // @namespace https://greasyforks.org/scripts/4397 // ==/UserScript== var alreadyPrefetched = {}; var excludedPatterns = /sign[\s_-]?in|sign[\s_-]?out|log[\s_-]?in|log[\s_-]?out|sign[\s_-]?up|subscribe|edit|delete|remove|send|apply|confirm|register/i; var prefetchStartTimerID = 0; function testRegExp(regexp, strings) { for (var i = 0; i < strings.length; i++) { if (regexp.test(strings[i])) return true; } return false; } $("body").on("mouseenter", "a", function (e) { var anchorObject = $(e.target); var anchorHref = anchorObject.attr("href"); var anchorInnerText = anchorObject.text(); var anchorTitle = anchorObject.attr("title"); if (anchorHref === undefined || alreadyPrefetched[anchorHref]) return; if (/^#/.test(anchorHref) || testRegExp(excludedPatterns, [anchorHref, anchorInnerText, anchorTitle])) { GM_log("Did not prefetch \"" + anchorHref + "\" because it contained an excluded pattern."); return; } clearTimeout(prefetchStartTimerID); prefetchStartTimerID = setTimeout(function () { GM_xmlhttpRequest({ method: "GET", url: anchorHref, onload: function() { GM_log("Prefetched \"" + anchorHref + "\"."); }}); alreadyPrefetched[anchorHref] = true; }, 200); }) $("body").on("mouseout", "a", function (e) { clearTimeout(prefetchStartTimerID); });