无须确认,直接跳转

让链接跳转提示自动跳转

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name          无须确认,直接跳转
// @namespace     Don't confirm, just redirect.
// @match         *://none/
// @grant         none
// @version       0.0.3
// @author        -
// @description   让链接跳转提示自动跳转
// ==/UserScript==
const rules = [
  { // Weibo
    reg: /^https?:\/\/t.cn\/\w+/i,
    isit: () => { return document.body.querySelectorAll('p').length === 2 && document.body.querySelectorAll('p.link').length === 1 },
    link: () => { return document.body.querySelector('p.link').innerText }
  },
  { // Other
    reg: /https?%3A(?:%2F%2F|\/\/)/i,
    isit: true,
    link: ()=>{ return decodeURIComponent(
      window.location.search
        .replace(/^.*?(https?%3A(?:%2F%2F|\/\/))/, '$1')
        .replace(/&.*$/, '')
    ) }
  }
]
for(const rule of rules){
  if(rule.reg.test(window.location.href)){
    if(rule.isit()){
      window.location.href = rule.link()
    }
    break;
  }
}