简单搜索自动展开

自动展开简单搜索的结果,避免需要多次点击“加载更多”按钮。

// ==UserScript==
// @name         简单搜索自动展开
// @description  自动展开简单搜索的结果,避免需要多次点击“加载更多”按钮。
// @author       ChatGPT
// @version      3.4
// @match        https://m.baidu.com/*
// @match        https://www.baidu.com/*
// @run-at      document-end
// @grant        none
// @namespace https://greasyfork.org/users/452911
// ==/UserScript==

if (window.location.href.includes('word=') || window.location.href.includes('wd=')) {
    window.addEventListener('scroll', function() {
        var distanceToBottom = document.body.scrollHeight - (window.innerHeight + window.pageYOffset);

        if (distanceToBottom < 400) {
            var loadMoreButton = document.querySelector('div.se-infiniteload-text');
            if (loadMoreButton) {
                loadMoreButton.click();
            }
        }
    });

    var div = document.getElementById("head-queryarea");
    if (div) {
        div.style.display = "none";
    }
}