Greasy Fork is available in English.

手机百度搜索跳过中间页

自动跳过手机百度搜索结果底部大家都在搜的中间页,直接打开目标网页链接。

// ==UserScript==
// @name         手机百度搜索跳过中间页
// @version      1.0
// @description  自动跳过手机百度搜索结果底部大家都在搜的中间页,直接打开目标网页链接。
// @author       ChatGPT
// @match        https://www.baidu.com/*
// @match        https://m.baidu.com/*
// @run-at       document-idle
// @grant        none
// @namespace https://greasyfork.org/users/452911
// ==/UserScript==

(function() {
    'use strict';

    const url = window.location.href;
    if (url.indexOf("wd=") !== -1 || url.indexOf("word=") !== -1) {
        // 获取A标签元素
        var links = document.querySelectorAll("a.new-nextpage,a.new-nextpage-only,a.c-fwb.c-slink.c-blocka.c-slink-new-strong");

        // 遍历链接
        for (var i = 0; i < links.length; i++) {
            // 添加点击事件监听器
            links[i].addEventListener("click", function(e) {
                e.preventDefault();
                var link = this;
                // 延迟0.1秒后在当前标签中打开链接
                setTimeout(function() {
                    window.location.href = link.href;
                }, 100);
            });
        }
    }
})();