在zh.cppreference.com上的搜索引擎从DuckDuckGo替换为百度
// ==UserScript==
// @name C++参考手册搜索引擎替换
// @namespace https://github.com/guitarandherandher
// @version 0.1
// @description 在zh.cppreference.com上的搜索引擎从DuckDuckGo替换为百度
// @author 吉他及她
// @license MIT
// @match https://zh.cppreference.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 等待DOM完全加载
window.addEventListener('load', function() {
var searchForm = document.querySelector('form[action="https://duckduckgo.com/"]');
if (searchForm) {
searchForm.action = 'https://www.baidu.com/s';
var searchInput = searchForm.querySelector('input[name="q"]');
if (searchInput) {
searchInput.name = 'wd';
searchForm.addEventListener('submit', function() {
searchInput.value += ' site:zh.cppreference.com';
});
}
}
});
})();