FreeJump

2024/3/23 12:14:00

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        FreeJump
// @namespace   xanderwang.site
// @include      *://*
// @grant       none
// @version     1.0
// @author      xanderwang
// @license MIT
// @description 2024/3/23 12:14:00
// ==/UserScript==

(function () {
  'use strict';
  function openNewTab(linkUrl) {
    // alert(`open: ${linkUrl}`)
    // 使用window.open打开新的标签页
    window.open(linkUrl, '_blank');
    // 阻止默认的链接跳转行为(如果需要)
    return false;
  }
  let aTags = document.getElementsByTagName('a')
  for (let index = 0; index < aTags.length; index++) {
    let linkUrl = aTags[index].href
    const parts = linkUrl.split('=http');
    if (parts.length > 1) {
      console.log(`find: ${linkUrl}`)
      let site = decodeURIComponent(parts[1].split(' ')[0])
      linkUrl = `http${site}`;
      console.log(`final:${linkUrl}`)
      aTags[index].onclick = openNewTab(linkUrl);
    }
    aTags[index].href = linkUrl
  }

})(); //(function(){})() 表示该函数立即执行