您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
将Yandex搜索结果改为双列显示布局
当前为
// ==UserScript== // @name Yandex双列显示 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 将Yandex搜索结果改为双列显示布局 // @author 您的名字 // @match *://yandex.com/search* // @match *://yandex.ru/search* // @grant GM_addStyle // ==/UserScript== (function() { 'use strict'; // 添加CSS样式使搜索结果变为双列 GM_addStyle(` /* 主容器样式 */ .main.content_left { width: 100% !important; max-width: 100% !important; } /* 搜索结果容器 */ .serp-list { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 20px; width: 100%; } /* 搜索结果项目 */ .serp-item { width: 100%; margin-bottom: 15px; border: 1px solid #e0e0e0; border-radius: 8px; padding: 10px; box-sizing: border-box; box-shadow: 0 1px 3px rgba(0,0,0,0.1); transition: box-shadow 0.3s ease; } .serp-item:hover { box-shadow: 0 3px 8px rgba(0,0,0,0.15); } /* 调整右侧广告栏 */ .content__right { position: relative !important; width: 100% !important; margin-top: 20px; } /* 响应式设计 - 在小屏幕上恢复单列 */ @media (max-width: 1024px) { .serp-list { grid-template-columns: 1fr; } } `); // 监听DOM变化,以便在动态加载内容时也应用样式 function setupObserver() { const targetNode = document.body; const config = { childList: true, subtree: true }; const callback = function(mutationsList, observer) { for(const mutation of mutationsList) { if (mutation.type === 'childList') { // 确保样式应用于新加载的元素 const serpLists = document.querySelectorAll('.serp-list:not(.processed-by-userscript)'); serpLists.forEach(list => { list.classList.add('processed-by-userscript'); }); } } }; const observer = new MutationObserver(callback); observer.observe(targetNode, config); } // 页面加载完成后执行 window.addEventListener('load', function() { setupObserver(); // 给最初的搜索结果列表添加标记 const initialLists = document.querySelectorAll('.serp-list'); initialLists.forEach(list => { list.classList.add('processed-by-userscript'); }); }); })();