- // ==UserScript==
- // @name 网站URL简化|去除杂乱参数
- // @namespace http://tampermonkey.net/
- // @version 1.8
- // @description 自动清理必应搜索、B站视频、百度搜索、KIMI AI和360搜索等的URL中的多余参数,优化浏览体验
- // @author xjy666a
- // @license MIT
- // @match https://cn.bing.com/search*
- // @match https://www.bing.com/search*
- // @match https://www.bilibili.com/video/*
- // @match https://www.baidu.com/*
- // @match https://kimi.moonshot.cn/*
- // @match https://minecraft.fandom.com/*
- // @match https://www.so.com/s*
- // @grant GM_getValue
- // @grant GM_setValue
- // @grant GM_registerMenuCommand
- // @grant GM_unregisterMenuCommand
- // @grant GM_setClipboard
- // @grant unsafeWindow
- // @run-at document-start
- // @priority 1
- // @icon data:image/x-icon;base64,AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAKBEAAJ4EAAAwMAAAAQAgAGgmAADGFQAAKAAAABAAAAAgAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxMTEvMzMzljMzM9kzMzP6MzMz+TMzM9gyMjKVMjIyLgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgIAgzMzOXMzMz/TIyMsEzMzNuMjIySDIyMkgzMzNvMjIywTIyMv0zMzOWJCQkBwAAAAAAAAAAAAAAACAgIAgzMzO/MzMz5zMzM0YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxMTFEMzMz5TMzM70kJCQHAAAAAAAAAAAzMzOXMzMz6jIyMiQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAwMCAzMzPlMzMzlQAAAAAxMTEvMzMz/TIyMlEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMTExRDIyMv0yMjIuMzMzljIyMtAyMjJsMzMz2jIyMpM0NDRsMzMz3jMzM7UyMjIuMzMzaTMzM2kzMzNpMzMzaTQ0NFgyMjLAMzMzlTMzM9kzMzOBLi4uFjMzM/wzMzO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AAAAAAAAAAAAAAAAAAAAAAAAAAA==
- // ==/UserScript==
-
- /* MIT License
-
- Copyright (c) 2024 xjy666a
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
-
- (function() {
- 'use strict';
-
- // 默认设置
- const defaultSettings = {
- enableCleaner: true,
- enableBing: true,
- enableBilibili: true,
- enableBaidu: true,
- enableKimi: true,
- enableMinecraft: true,
- enable360: true,
- enableClipboardCleaner: true,
- usageCount: 0, // 添加使用计数
- ratingRequested: false // 添加评分请求标记
- };
-
- // 获取设置
- function getSettings() {
- return {
- enableCleaner: GM_getValue('enableCleaner', defaultSettings.enableCleaner),
- enableBing: GM_getValue('enableBing', defaultSettings.enableBing),
- enableBilibili: GM_getValue('enableBilibili', defaultSettings.enableBilibili),
- enableBaidu: GM_getValue('enableBaidu', defaultSettings.enableBaidu),
- enableKimi: GM_getValue('enableKimi', defaultSettings.enableKimi),
- enableMinecraft: GM_getValue('enableMinecraft', defaultSettings.enableMinecraft),
- enable360: GM_getValue('enable360', defaultSettings.enable360),
- enableClipboardCleaner: GM_getValue('enableClipboardCleaner', defaultSettings.enableClipboardCleaner),
- usageCount: GM_getValue('usageCount', 0),
- ratingRequested: GM_getValue('ratingRequested', false)
- };
- }
-
- // 切换设置并返回新状态
- function toggleSetting(key) {
- const currentValue = GM_getValue(key, defaultSettings[key]);
- GM_setValue(key, !currentValue);
- return !currentValue;
- }
-
- // 注册菜单命令
- function registerMenuCommands() {
- const settings = getSettings();
-
- // 主菜单项
- GM_registerMenuCommand(
- `📊 使用次数: ${settings.usageCount} 次`,
- () => showUsageStats()
- );
-
- GM_registerMenuCommand(
- `💬 提供反馈或建议`,
- () => showFeedbackPrompt()
- );
-
- GM_registerMenuCommand(
- `${settings.enableCleaner ? '✅' : '❌'} 启用URL清理`,
- () => {
- toggleSetting('enableCleaner');
- location.reload();
- }
- );
-
- // 网站设置子菜单
- GM_registerMenuCommand(
- `🔧 网站设置...`,
- () => showWebsiteSettings()
- );
- }
-
- // 显示使用统计详情
- function showUsageStats() {
- const settings = getSettings();
-
- // 创建统计信息弹窗
- const statsPrompt = document.createElement('div');
- statsPrompt.className = 'usage-stats-prompt';
- statsPrompt.style.cssText = `
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: rgba(34, 34, 34, 0.95);
- color: white;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
- z-index: 10001;
- font-size: 14px;
- min-width: 300px;
- text-align: center;
- transition: opacity 0.3s;
- `;
-
- // 计算使用天数(假设脚本安装日期存储在installDate中)
- const installDate = GM_getValue('installDate', Date.now());
- const daysUsed = Math.ceil((Date.now() - installDate) / (1000 * 60 * 60 * 24));
-
- // 弹窗内容
- statsPrompt.innerHTML = `
- <div style="margin-bottom: 15px; font-weight: bold; font-size: 16px;">URL简化脚本使用统计</div>
- <div style="margin-bottom: 10px; text-align: left; padding: 0 10px;">
- <div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
- <span>总使用次数:</span>
- <span style="font-weight: bold; color: #4CAF50;">${settings.usageCount} 次</span>
- </div>
- <div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
- <span>已使用天数:</span>
- <span style="font-weight: bold; color: #2196F3;">${daysUsed} 天</span>
- </div>
- <div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
- <span>平均每天使用:</span>
- <span style="font-weight: bold; color: #FFC107;">${(settings.usageCount / Math.max(daysUsed, 1)).toFixed(1)} 次</span>
- </div>
- </div>
- <button class="close-stats-prompt" style="
- background-color: #555;
- color: white;
- border: none;
- padding: 8px 15px;
- border-radius: 4px;
- cursor: pointer;
- margin-top: 10px;
- font-weight: bold;
- ">关闭</button>
- `;
-
- // 添加到页面
- document.body.appendChild(statsPrompt);
-
- // 关闭按钮点击事件
- statsPrompt.querySelector('.close-stats-prompt').addEventListener('click', function() {
- document.body.removeChild(statsPrompt);
- });
- }
-
- // 显示反馈弹窗
- function showFeedbackPrompt() {
- // 检查是否已存在弹窗
- if (document.querySelector('.feedback-prompt')) {
- return;
- }
-
- // 创建弹窗
- const prompt = document.createElement('div');
- prompt.className = 'feedback-prompt';
- prompt.style.cssText = `
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: rgba(34, 34, 34, 0.95);
- color: white;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
- z-index: 10001;
- font-size: 14px;
- max-width: 400px;
- text-align: center;
- transition: opacity 0.3s;
- `;
-
- // 弹窗内容
- prompt.innerHTML = `
- <div style="margin-bottom: 15px; font-weight: bold; font-size: 16px;">功能反馈与建议</div>
- <div style="margin-bottom: 20px; line-height: 1.5; text-align: left;">
- 目前本脚本功能较少,你可以反馈,若可以实现,我们会尽量满足!
- </div>
- <div style="display: flex; justify-content: center; margin-bottom: 15px;">
- <a href="https://scriptcat.org/zh-CN/script-show-page/2654/" target="_blank" style="
- display: inline-block;
- background-color: #4CAF50;
- color: white;
- text-decoration: none;
- padding: 8px 15px;
- border-radius: 4px;
- margin-right: 10px;
- font-weight: bold;
- ">在脚本猫反馈</a>
- <a href="https://greasyfork.org/zh-CN/scripts/524527-网站url简化-去除杂乱参数" target="_blank" style="
- display: inline-block;
- background-color: #2196F3;
- color: white;
- text-decoration: none;
- padding: 8px 15px;
- border-radius: 4px;
- font-weight: bold;
- ">在Greasy Fork反馈</a>
- </div>
- <button class="close-feedback-prompt" style="
- background-color: transparent;
- color: #ddd;
- border: 1px solid #666;
- padding: 5px 10px;
- border-radius: 4px;
- cursor: pointer;
- margin-top: 5px;
- ">关闭</button>
- `;
-
- // 添加到页面
- document.body.appendChild(prompt);
-
- // 关闭按钮点击事件
- prompt.querySelector('.close-feedback-prompt').addEventListener('click', function() {
- document.body.removeChild(prompt);
- });
-
- // 点击反馈链接时关闭弹窗
- prompt.querySelectorAll('a').forEach(link => {
- link.addEventListener('click', function() {
- setTimeout(() => {
- if (document.body.contains(prompt)) {
- document.body.removeChild(prompt);
- }
- }, 500);
- });
- });
- }
-
- // 显示网站设置弹窗
- function showWebsiteSettings() {
- const settings = getSettings();
-
- // 创建设置弹窗
- const settingsPrompt = document.createElement('div');
- settingsPrompt.className = 'website-settings-prompt';
- settingsPrompt.style.cssText = `
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: rgba(34, 34, 34, 0.95);
- color: white;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
- z-index: 10001;
- font-size: 14px;
- min-width: 300px;
- max-width: 500px;
- max-height: 80vh;
- overflow-y: auto;
- text-align: left;
- transition: opacity 0.3s;
- `;
-
- // 网站设置列表
- const websiteSettings = [
- { key: 'enableBing', name: '必应搜索', icon: '🔍' },
- { key: 'enableBilibili', name: 'B站视频', icon: '📺' },
- { key: 'enableBaidu', name: '百度搜索', icon: '🔍' },
- { key: 'enableKimi', name: 'KIMI AI', icon: '🤖' },
- { key: 'enableMinecraft', name: 'Minecraft Wiki重定向', icon: '🎮' },
- { key: 'enable360', name: '360搜索', icon: '🔍' },
- { key: 'enableClipboardCleaner', name: 'B站分享链接自动清理', icon: '��' }
- // 未来可以在这里添加更多网站
- ];
-
- // 构建设置项HTML
- let settingsHTML = `
- <div style="margin-bottom: 15px; font-weight: bold; font-size: 16px; text-align: center;">网站设置</div>
- <div style="margin-bottom: 15px;">
- 启用或禁用特定网站的URL清理功能:
- </div>
- <div style="display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center;">
- `;
-
- // 添加每个网站的设置项
- websiteSettings.forEach(site => {
- settingsHTML += `
- <div style="display: flex; align-items: center;">
- <span style="margin-right: 8px;">${site.icon}</span>
- <span>${site.name}</span>
- </div>
- <label class="switch" style="justify-self: end;">
- <input type="checkbox" data-key="${site.key}" ${settings[site.key] ? 'checked' : ''}>
- <span class="slider" style="
- position: relative;
- display: inline-block;
- width: 40px;
- height: 20px;
- background-color: ${settings[site.key] ? '#4CAF50' : '#ccc'};
- border-radius: 10px;
- transition: .4s;
- cursor: pointer;
- "></span>
- </label>
- `;
- });
-
- // 添加按钮
- settingsHTML += `
- </div>
- <div style="display: flex; justify-content: center; margin-top: 20px;">
- <button class="save-settings" style="
- background-color: #4CAF50;
- color: white;
- border: none;
- padding: 8px 15px;
- border-radius: 4px;
- cursor: pointer;
- margin-right: 10px;
- font-weight: bold;
- ">保存设置</button>
- <button class="close-settings" style="
- background-color: #555;
- color: white;
- border: none;
- padding: 8px 15px;
- border-radius: 4px;
- cursor: pointer;
- font-weight: bold;
- ">取消</button>
- </div>
- `;
-
- // 设置弹窗内容
- settingsPrompt.innerHTML = settingsHTML;
-
- // 添加到页面
- document.body.appendChild(settingsPrompt);
-
- // 切换开关样式
- settingsPrompt.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
- checkbox.addEventListener('change', function() {
- const slider = this.nextElementSibling;
- slider.style.backgroundColor = this.checked ? '#4CAF50' : '#ccc';
- });
- });
-
- // 保存按钮点击事件
- settingsPrompt.querySelector('.save-settings').addEventListener('click', function() {
- // 保存所有设置
- settingsPrompt.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
- const key = checkbox.dataset.key;
- GM_setValue(key, checkbox.checked);
- });
-
- // 显示保存成功通知
- showNotification('设置已保存');
-
- // 关闭弹窗
- document.body.removeChild(settingsPrompt);
-
- // 重新加载页面以应用设置
- location.reload();
- });
-
- // 关闭按钮点击事件
- settingsPrompt.querySelector('.close-settings').addEventListener('click', function() {
- document.body.removeChild(settingsPrompt);
- });
- }
-
- // 增加使用计数并检查是否需要请求评分
- function incrementUsageCount() {
- const settings = getSettings();
-
- // 增加使用计数
- const newCount = settings.usageCount + 1;
- GM_setValue('usageCount', newCount);
-
- // 检查是否需要请求评分 - 将阈值从50改为10
- if (newCount >= 10 && !settings.ratingRequested) {
- // 显示评分请求
- showRatingPrompt();
- // 标记已请求评分
- GM_setValue('ratingRequested', true);
- }
- }
-
- // 显示评分请求提示
- function showRatingPrompt() {
- // 检查是否已存在提示框
- if (document.querySelector('.rating-prompt')) {
- return;
- }
-
- // 创建提示框
- const prompt = document.createElement('div');
- prompt.className = 'rating-prompt';
- prompt.style.cssText = `
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: rgba(34, 34, 34, 0.95);
- color: white;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
- z-index: 10001;
- font-size: 14px;
- max-width: 400px;
- text-align: center;
- transition: opacity 0.3s;
- `;
-
- // 提示框内容 - 修改文本以反映新的阈值
- prompt.innerHTML = `
- <div style="margin-bottom: 15px; font-weight: bold; font-size: 16px;">感谢您使用URL简化脚本!</div>
- <div style="margin-bottom: 20px; line-height: 1.5;">
- 您已经使用本脚本超过10次,如果觉得它对您有帮助,希望您能花一点时间给它评个分,这将帮助更多人发现它。
- </div>
- <div style="display: flex; justify-content: center; margin-bottom: 15px;">
- <a href="https://scriptcat.org/zh-CN/script-show-page/2654/" target="_blank" style="
- display: inline-block;
- background-color: #4CAF50;
- color: white;
- text-decoration: none;
- padding: 8px 15px;
- border-radius: 4px;
- margin-right: 10px;
- font-weight: bold;
- ">在脚本猫评分</a>
- <a href="https://greasyfork.org/zh-CN/scripts/524527-网站url简化-去除杂乱参数" target="_blank" style="
- display: inline-block;
- background-color: #2196F3;
- color: white;
- text-decoration: none;
- padding: 8px 15px;
- border-radius: 4px;
- font-weight: bold;
- ">在Greasy Fork评分</a>
- </div>
- <button class="close-rating-prompt" style="
- background-color: transparent;
- color: #ddd;
- border: 1px solid #666;
- padding: 5px 10px;
- border-radius: 4px;
- cursor: pointer;
- margin-top: 5px;
- ">稍后再说</button>
- <div style="font-size: 12px; margin-top: 15px; color: #aaa;">
- 您的支持是我们持续改进的动力!
- </div>
- `;
-
- // 添加到页面
- document.body.appendChild(prompt);
-
- // 关闭按钮点击事件
- prompt.querySelector('.close-rating-prompt').addEventListener('click', function() {
- document.body.removeChild(prompt);
- });
-
- // 点击评分链接时关闭提示框
- prompt.querySelectorAll('a').forEach(link => {
- link.addEventListener('click', function() {
- // 标记用户已点击评分链接
- GM_setValue('userRated', true);
- setTimeout(() => {
- if (document.body.contains(prompt)) {
- document.body.removeChild(prompt);
- }
- }, 500);
- });
- });
- }
-
- // 清理URL的函数
- function cleanUrl(url) {
- try {
- const settings = getSettings();
- if (!settings.enableCleaner) {
- return url;
- }
-
- // 增加使用计数
- incrementUsageCount();
-
- const urlObj = new URL(url);
-
- // 处理Minecraft Wiki重定向
- if (settings.enableMinecraft && urlObj.hostname === 'minecraft.fandom.com') {
- const pathParts = urlObj.pathname.split('/');
- let newUrl;
-
- if (pathParts[1] === 'wiki') {
- const pageName = pathParts.slice(2).join('/');
- newUrl = `https://en.minecraft.wiki/w/${pageName}`;
- } else if (pathParts[2] === 'wiki') {
- const lang = pathParts[1];
- const pageName = pathParts.slice(3).join('/');
- newUrl = `https://${lang}.minecraft.wiki/w/${pageName}`;
- }
-
- if (newUrl && newUrl !== url) {
- window.location.href = newUrl;
- return url;
- }
- }
-
- // 处理KIMI AI URL
- if (settings.enableKimi && urlObj.hostname === 'kimi.moonshot.cn') {
- if (urlObj.pathname === '/' || urlObj.pathname === '') {
- const newUrl = 'https://kimi.moonshot.cn/';
- if (newUrl !== url) {
- window.location.href = newUrl;
- return url;
- }
- return newUrl;
- }
- }
-
- // 处理百度搜索URL(已修复空格编码)
- if (settings.enableBaidu && urlObj.hostname === 'www.baidu.com' && urlObj.pathname === '/s') {
- const wd = urlObj.searchParams.get('wd');
- const pn = urlObj.searchParams.get('pn');
-
- if (wd) {
- let newUrl = `https://www.baidu.com/s?wd=${encodeURIComponent(wd).replace(/%20/g, '+')}`;
- if (pn) {
- newUrl += `&pn=${pn}`;
- }
- if (newUrl !== url) {
- window.location.href = newUrl;
- return url;
- }
- return newUrl;
- }
- }
-
- // 处理Bing搜索URL (包括国际版)
- if (settings.enableBing && (urlObj.hostname === 'cn.bing.com' || urlObj.hostname === 'www.bing.com') && urlObj.pathname === '/search') {
- const searchQuery = urlObj.searchParams.get('q');
- const firstParam = urlObj.searchParams.get('first');
-
- if (searchQuery) {
- // 保持原始域名不变
- let newUrl = `https://${urlObj.hostname}/search?q=${encodeURIComponent(searchQuery)}`;
- if (firstParam) {
- newUrl += `&first=${firstParam}`;
- }
- if (newUrl !== url) {
- window.location.href = newUrl;
- return url;
- }
- return newUrl;
- }
- }
-
- // 处理B站视频URL
- if (settings.enableBilibili && urlObj.hostname === 'www.bilibili.com' && urlObj.pathname.startsWith('/video/')) {
- const bvMatch = urlObj.pathname.match(/\/video\/(BV[\w]+)/);
- if (bvMatch) {
- const bvid = bvMatch[1];
- const newUrl = `https://www.bilibili.com/video/${bvid}`;
- // 只返回新URL,不进行跳转
- return newUrl;
- }
- }
-
- // 处理360搜索URL
- if (settings.enable360 && urlObj.hostname === 'www.so.com' && urlObj.pathname === '/s') {
- const q = urlObj.searchParams.get('q');
- const pn = urlObj.searchParams.get('pn');
-
- if (q) {
- let newUrl = `https://www.so.com/s?q=${encodeURIComponent(q)}`;
- if (pn) {
- newUrl += `&pn=${pn}`;
- }
- if (newUrl !== url) {
- window.location.href = newUrl;
- return url;
- }
- return newUrl;
- }
- }
-
- return url;
- } catch (error) {
- console.error('URL处理错误:', error);
- return url;
- }
- }
-
- // 检查并清理当前URL
- function checkAndCleanUrl() {
- const currentUrl = window.location.href;
- const cleanedUrl = cleanUrl(currentUrl);
-
- if (cleanedUrl !== currentUrl) {
- // 使用 history.replaceState 来更新URL而不刷新页面
- window.history.replaceState(null, '', cleanedUrl);
- }
- }
-
- // 监听URL变化
- let lastUrl = window.location.href;
- new MutationObserver(() => {
- const currentUrl = window.location.href;
- if (currentUrl !== lastUrl) {
- lastUrl = currentUrl;
- checkAndCleanUrl();
- }
- }).observe(document, {subtree: true, childList: true});
-
- // 处理必应搜索结果中的Minecraft Wiki链接
- function processBingSearchResults() {
- // 同时支持中国版和国际版必应
- if (!window.location.href.includes('.bing.com/search')) return;
-
- // 检查页面是否有内容
- const mainResults = document.getElementById('b_results') ||
- document.querySelector('.b_results') ||
- document.querySelector('#main');
-
- // 修改判断条件:检查搜索结果是否存在且内容是否足够
- if (!mainResults || mainResults.children.length < 2) {
- console.log('必应搜索结果似乎为空,准备重试...');
-
- // 重试机制
- if (typeof window.bingRetryCount === 'undefined') {
- window.bingRetryCount = 0;
- }
-
- if (window.bingRetryCount < 3) {
- window.bingRetryCount++;
- console.log(`重试第 ${window.bingRetryCount} 次...`);
-
- // 延迟2秒后重试,给予更多加载时间
- setTimeout(() => {
- // 如果已经重试了但还是没有结果,保留参数重新加载
- if (window.bingRetryCount >= 2) {
- console.log('尝试保留参数重新加载...');
- sessionStorage.setItem('cleanUrlAfterLoad', 'true');
- window.location.reload(true); // 强制从服务器重新加载
- } else {
- window.location.reload();
- }
- }, 2000);
-
- return;
- } else {
- console.log('已达到最大重试次数,保留参数加载页面');
- // 标记为已处理,避免无限循环
- window.bingRetryHandled = true;
-
- // 获取当前URL并保留所有参数
- const currentUrl = window.location.href;
-
- // 设置一个标记,表示页面已经加载完成后再清理URL
- sessionStorage.setItem('cleanUrlAfterLoad', 'true');
- sessionStorage.setItem('originalUrl', currentUrl);
-
- // 不再尝试清理URL,让页面正常加载
- return;
- }
- } else {
- // 如果页面加载成功,重置计数器
- window.bingRetryCount = 0;
-
- // 检查是否需要在页面加载后清理URL
- if (sessionStorage.getItem('cleanUrlAfterLoad') === 'true') {
- const originalUrl = sessionStorage.getItem('originalUrl');
- sessionStorage.removeItem('cleanUrlAfterLoad');
- sessionStorage.removeItem('originalUrl');
-
- // 延迟执行URL清理,确保页面已完全加载
- setTimeout(() => {
- if (mainResults && mainResults.children.length > 2) {
- checkAndCleanUrl();
- }
- }, 2000);
- }
- }
-
- // 获取所有未处理的搜索结果链接
- const searchResults = mainResults.querySelectorAll('a[href*="minecraft.fandom.com"]:not([data-wiki-processed])');
-
- searchResults.forEach(link => {
- try {
- // 标记该链接已处理
- link.setAttribute('data-wiki-processed', 'true');
-
- const url = new URL(link.href);
- if (url.hostname === 'minecraft.fandom.com') {
- const pathParts = url.pathname.split('/');
- let newUrl;
-
- // 构建新的Wiki URL
- if (pathParts[1] === 'wiki') {
- const pageName = pathParts.slice(2).join('/');
- newUrl = `https://en.minecraft.wiki/w/${pageName}`;
- } else if (pathParts[2] === 'wiki') {
- const lang = pathParts[1];
- const pageName = pathParts.slice(3).join('/');
- newUrl = `https://${lang}.minecraft.wiki/w/${pageName}`;
- }
-
- if (newUrl) {
- // 获取搜索结果容器
- const resultContainer = link.closest('li') || link.parentElement;
-
- // 设置结果容器样式
- resultContainer.style.position = 'relative';
- resultContainer.style.color = '#666';
- resultContainer.style.pointerEvents = 'none';
-
- // 创建新链接提示
- const notice = document.createElement('div');
- notice.style.cssText = `
- margin-top: 8px;
- padding: 8px;
- background: #f8f8f8;
- border-radius: 4px;
- pointer-events: auto;
- `;
- notice.innerHTML = `
- <div style="color: #e74c3c; font-size: 0.9em; margin-bottom: 4px;">
- ⚠️ 上述链接指向已弃用的旧版Wiki
- </div>
- <a href="${newUrl}" style="
- display: inline-block;
- color: #2ecc71;
- font-weight: bold;
- text-decoration: none;
- ">
- 👉 访问新版Wiki页面
- </a>
- `;
-
- // 添加新链接提示
- resultContainer.appendChild(notice);
- }
- }
- } catch (error) {
- console.error('处理搜索结果链接时出错:', error);
- }
- });
- }
-
- // 使用防抖函数来限制处理频率
- function debounce(func, wait) {
- let timeout;
- return function executedFunction(...args) {
- const later = () => {
- clearTimeout(timeout);
- func(...args);
- };
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- };
- }
-
- // 监听页面变化以处理动态加载的搜索结果
- function observeSearchResults() {
- const debouncedProcess = debounce(processBingSearchResults, 300);
-
- // 创建观察器
- const observer = new MutationObserver(() => {
- // 兼容不同版本的必应
- if (document.getElementById('b_results') ||
- document.querySelector('.b_results') ||
- document.querySelector('#main')) {
- debouncedProcess();
- }
- });
-
- // 观察整个body
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
-
- // 首次处理
- processBingSearchResults();
-
- // 监听URL变化
- let lastUrl = location.href;
- const urlChecker = setInterval(() => {
- if (location.href !== lastUrl) {
- lastUrl = location.href;
- // 重置重试计数器
- window.bingRetryCount = 0;
- processBingSearchResults();
- }
- }, 500);
-
- // 清理函数
- return () => {
- observer.disconnect();
- clearInterval(urlChecker);
- };
- }
-
- // 修改B站分享链接清理函数
- function cleanBilibiliShareLink(text) {
- // 检查是否包含B站视频链接
- if (!text.includes('bilibili.com/video/BV')) {
- return text;
- }
-
- try {
- // 检查是否已经是清理过的链接(被||包围的标题)
- if (text.match(/\|\|.+?\|\|\s+https:\/\/www\.bilibili\.com\/video\/BV[\w]+\//)) {
- return text;
- }
-
- // 提取BV号
- const bvMatch = text.match(/bilibili\.com\/video\/(BV[\w]+)/);
- if (!bvMatch) return text;
-
- const bvid = bvMatch[1];
-
- // 检查是否有标题格式【标题】
- const titleMatch = text.match(/【(.+?)】/);
- const title = titleMatch ? titleMatch[1] : '';
-
- // 构建清理后的链接
- const cleanedUrl = `https://www.bilibili.com/video/${bvid}/`;
-
- // 返回清理后的完整文本,使用||包围标题
- if (title) {
- return `||${title}|| ${cleanedUrl}`;
- } else {
- return cleanedUrl;
- }
- } catch (error) {
- console.error('清理B站分享链接时出错:', error);
- return text;
- }
- }
-
- // B站专用剪贴板监听函数
- function monitorBilibiliClipboard() {
- // 只在B站页面上运行
- if (!window.location.hostname.includes('bilibili.com')) return;
-
- const settings = getSettings();
- if (!settings.enableClipboardCleaner || !settings.enableBilibili) return;
-
- // 存储已处理的链接,避免重复处理
- const processedLinks = new Set();
-
- // 定期检查剪贴板内容
- const clipboardCheckInterval = setInterval(() => {
- navigator.clipboard.readText().then(text => {
- // 如果文本已经是清理过的格式(被||包围的标题),跳过
- if (text.match(/\|\|.+?\|\|\s+https:\/\/www\.bilibili\.com\/video\/BV[\w]+\//)) {
- return;
- }
-
- // 检查是否是B站链接且包含参数
- if (text && text.includes('bilibili.com/video/BV') && text.includes('?')) {
- // 生成唯一标识,避免重复处理相同链接
- const linkId = text.trim();
-
- // 如果已经处理过这个链接,跳过
- if (processedLinks.has(linkId)) return;
-
- // 添加到已处理集合
- processedLinks.add(linkId);
-
- // 清理链接
- const cleanedText = cleanBilibiliShareLink(text);
-
- // 如果清理后有变化,显示提示
- if (cleanedText !== text) {
- // 增加使用计数
- incrementUsageCount();
-
- // 显示提示框让用户选择复制简化链接
- showCleanLinkPrompt(cleanedText);
- }
-
- // 限制已处理链接集合大小,避免内存泄漏
- if (processedLinks.size > 50) {
- const iterator = processedLinks.values();
- processedLinks.delete(iterator.next().value);
- }
- }
- }).catch(err => {
- console.error('读取剪贴板失败:', err);
- });
- }, 1000); // 每秒检查一次
-
- // 页面卸载时清除定时器
- window.addEventListener('unload', () => {
- clearInterval(clipboardCheckInterval);
- });
-
- // 仍然保留复制事件监听,以便更及时地响应
- document.addEventListener('copy', function() {
- setTimeout(() => {
- navigator.clipboard.readText().then(text => {
- // 如果文本已经是清理过的格式,跳过
- if (text.match(/\|\|.+?\|\|\s+https:\/\/www\.bilibili\.com\/video\/BV[\w]+\//)) {
- return;
- }
-
- if (text && text.includes('bilibili.com/video/BV') && text.includes('?')) {
- const linkId = text.trim();
- if (processedLinks.has(linkId)) return;
-
- processedLinks.add(linkId);
- const cleanedText = cleanBilibiliShareLink(text);
- if (cleanedText !== text) {
- // 增加使用计数
- incrementUsageCount();
-
- // 显示提示框让用户选择复制简化链接
- showCleanLinkPrompt(cleanedText);
- }
- }
- }).catch(err => console.error('读取剪贴板失败:', err));
- }, 200);
- });
- }
-
- // 显示清理链接提示框
- function showCleanLinkPrompt(cleanedText) {
- // 检查是否已存在提示框,避免重复显示
- if (document.querySelector('.clean-link-prompt')) {
- return;
- }
-
- // 创建提示框
- const prompt = document.createElement('div');
- prompt.className = 'clean-link-prompt';
- prompt.style.cssText = `
- position: fixed;
- bottom: 20px;
- right: 20px;
- background-color: rgba(34, 34, 34, 0.9);
- color: white;
- padding: 15px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
- z-index: 10000;
- font-size: 14px;
- max-width: 300px;
- transition: opacity 0.3s;
- `;
-
- // 提示框内容
- prompt.innerHTML = `
- <div style="margin-bottom: 10px; font-weight: bold;">检测到B站分享链接</div>
- <div style="margin-bottom: 12px; color: #ddd; font-size: 12px; word-break: break-all;">${cleanedText}</div>
- <button class="copy-clean-link" style="
- background-color: #00a1d6;
- color: white;
- border: none;
- padding: 5px 10px;
- border-radius: 4px;
- cursor: pointer;
- margin-right: 10px;
- ">复制简化链接</button>
- <button class="close-prompt" style="
- background-color: transparent;
- color: #ddd;
- border: 1px solid #666;
- padding: 5px 10px;
- border-radius: 4px;
- cursor: pointer;
- ">关闭</button>
- `;
-
- // 添加到页面
- document.body.appendChild(prompt);
-
- // 复制按钮点击事件
- prompt.querySelector('.copy-clean-link').addEventListener('click', function() {
- GM_setClipboard(cleanedText);
- showNotification('已复制简化链接');
- document.body.removeChild(prompt);
- });
-
- // 关闭按钮点击事件
- prompt.querySelector('.close-prompt').addEventListener('click', function() {
- document.body.removeChild(prompt);
- });
-
- // 10秒后自动关闭
- setTimeout(() => {
- if (document.body.contains(prompt)) {
- prompt.style.opacity = '0';
- setTimeout(() => {
- if (document.body.contains(prompt)) {
- document.body.removeChild(prompt);
- }
- }, 300);
- }
- }, 10000);
- }
-
- // 显示通知
- function showNotification(message) {
- // 创建通知元素
- const notification = document.createElement('div');
- notification.textContent = message;
- notification.style.cssText = `
- position: fixed;
- bottom: 20px;
- right: 20px;
- background-color: rgba(0, 0, 0, 0.7);
- color: white;
- padding: 10px 15px;
- border-radius: 4px;
- z-index: 9999;
- font-size: 14px;
- transition: opacity 0.3s;
- `;
-
- // 添加到页面
- document.body.appendChild(notification);
-
- // 2秒后淡出
- setTimeout(() => {
- notification.style.opacity = '0';
- setTimeout(() => {
- document.body.removeChild(notification);
- }, 300);
- }, 2000);
- }
-
- // 初始化
- function init() {
- // 记录安装日期(如果尚未记录)
- if (!GM_getValue('installDate')) {
- GM_setValue('installDate', Date.now());
- }
-
- // 检查是否是从重试后的页面加载
- const needCleanAfterLoad = sessionStorage.getItem('cleanUrlAfterLoad') === 'true';
-
- // 如果不是重试后的页面加载,正常注册菜单和清理URL
- if (!needCleanAfterLoad) {
- registerMenuCommands();
- checkAndCleanUrl();
- } else {
- // 如果是重试后的页面加载,只注册菜单,不立即清理URL
- registerMenuCommands();
- console.log('页面通过保留参数加载,将在加载完成后清理URL');
- }
-
- // 重置必应重试计数器
- window.bingRetryCount = 0;
- window.bingRetryHandled = false;
-
- // 如果是必应搜索页面(包括国际版),处理搜索结果
- if (window.location.href.includes('.bing.com/search')) {
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', observeSearchResults);
- } else {
- observeSearchResults();
- }
- }
-
- // 设置B站专用剪贴板监听
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', monitorBilibiliClipboard);
- } else {
- monitorBilibiliClipboard();
- }
- }
-
- init();
- })();