您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
每条新闻独占一行
当前为
// ==UserScript== // @name 强制联合早报新闻一行一条 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 每条新闻独占一行 // @match https://www.zaobao.com/* // @match https://www.zaobao.com.sg/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function makeOneLine() { // 1. 让每条新闻独占一行 document.querySelectorAll('.list-block').forEach(item => { // 移除所有 Bootstrap 列相关 class item.classList.remove('col-lg-4', 'col-12', 'row', 'no-gutters'); // 强制独占一行 item.style.display = 'block'; item.style.width = '100%'; item.style.boxSizing = 'border-box'; item.style.margin = '0'; item.style.padding = '2px 0'; // 内容不换行 item.style.whiteSpace = 'nowrap'; item.style.overflow = 'hidden'; item.style.textOverflow = 'ellipsis'; // 让内部所有div都变成inline item.querySelectorAll('div').forEach(div => { div.style.display = 'inline'; div.style.whiteSpace = 'nowrap'; div.style.margin = '0 8px 0 0'; div.style.padding = '0'; }); }); // 2. 让父容器不再是flex/grid document.querySelectorAll('.row.reset-row-margin').forEach(row => { row.style.display = 'block'; }); // 2.1 去除主新闻列表分隔线(包括伪元素) document.querySelectorAll('.list-container, .list-block').forEach(el => { el.style.border = 'none'; el.style.borderBottom = 'none'; el.style.background = 'none'; el.style.boxShadow = 'none'; }); // 动态注入样式去除伪元素分隔线(加强版) if (!document.getElementById('remove-main-list-divider-style')) { const style = document.createElement('style'); style.id = 'remove-main-list-divider-style'; style.innerHTML = ` .list-container:after, .list-container:before, .list-block:after, .list-container .row.reset-row-margin:after { border: none !important; background: none !important; background-color: transparent !important; box-shadow: none !important; height: 0 !important; width: 0 !important; margin: 0 !important; padding: 0 !important; content: '' !important; display: none !important; position: static !important; z-index: 0 !important; top: auto !important; bottom: auto !important; left: auto !important; right: auto !important; clear: both !important; float: none !important; visibility: hidden !important; opacity: 0 !important; } `; document.head.appendChild(style); } // 3. 隐藏延伸阅读区块 document.querySelectorAll('section.further-reading').forEach(el => { el.style.display = 'none'; }); // 针对 /news/china 页面主新闻列表一行化 document.querySelectorAll('.list-block').forEach(item => { // 隐藏缩略图 const pic = item.querySelector('.summary-pic'); if (pic) pic.style.display = 'none'; // 只显示标题 item.querySelectorAll('.flex-1 > *').forEach(child => { if (!child.classList.contains('f18') && !child.classList.contains('m-eps')) { child.style.display = 'none'; } }); // 标题一行显示 const title = item.querySelector('.f18.m-eps'); if (title) { title.style.display = 'inline'; title.style.whiteSpace = 'nowrap'; title.style.overflow = 'hidden'; title.style.textOverflow = 'ellipsis'; title.style.fontWeight = 'bold'; title.style.fontSize = 'inherit'; title.style.color = ''; } // 每条新闻独占一行 item.style.display = 'block'; item.style.width = '100%'; item.style.boxSizing = 'border-box'; item.style.margin = '0'; item.style.padding = '2px 0'; item.style.whiteSpace = 'nowrap'; item.style.overflow = 'hidden'; item.style.textOverflow = 'ellipsis'; // 还原定位 item.style.position = 'static'; item.style.left = ''; item.style.top = ''; }); } // 页面加载后执行 window.addEventListener('load', makeOneLine); // 监听DOM变化(防止异步加载) const observer = new MutationObserver(makeOneLine); observer.observe(document.body, { childList: true, subtree: true }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址