Greasy Fork

直接访问链接

避免链接的二次点击

当前为 2023-02-02 提交的版本,查看 最新版本

// ==UserScript==
// @name        直接访问链接
// @description 避免链接的二次点击
// @namespace   https://gitee.com/inch_whf/tampermonkey-script-inch
// @version     1.1
// @author      wuhongfei
// @license     MIT
// @grant       none
// @include     *
// ==/UserScript==

(function(){
    var href = getQueryVariable("target") || getQueryVariable("url")
    if( href != null ){
        console.log(href);
        window.location.href = decodeURIComponent(href);
    }
})();

// 参考:https://www.runoob.com/w3cnote/js-get-url-param.html
function getQueryVariable(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if(pair[0] == variable){return pair[1];}
    }
    return null;
}