您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
可以在豆瓣小组列表页面快速预览帖子内容,无须再打开新窗口
当前为
// ==UserScript== // @name 豆瓣小组话题快速预览-douban group topic fast preview // @namespace https://openuserjs.org/scripts/dragoncat // @version 0.1 // @license MIT // @description 可以在豆瓣小组列表页面快速预览帖子内容,无须再打开新窗口 // @author 铛铛铛铛铛/https://www.douban.com/people/48915223 // @copyright 1991-2018,铛铛铛铛铛-Dragoncat // @match https://www.douban.com/group/* // @grant none // ==/UserScript== (function () { 'use strict'; const isTopicPage = location.pathname.match(/\/group\/topic/) const style = document.createElement("style") style.type = "text/css" if(!isTopicPage){ style.innerHTML = ` ::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: #656565; box-shadow: inset 0 0 5px rgba(0,0,0,.1); } ::-webkit-scrollbar-thumb:hover { background: #323232; } ::-webkit-scrollbar-track { background: #ededed; box-shadow: inset 0 0 5px rgba(0,0,0,.1); } #wrapper{ margin:0; width: 100%; box-sizing: border-box; } table.olt tr:not(.th):hover,table.olt tr:not(.th).active{ cursor: pointer; background: #f2f8f2; } .grid-16-8 .article{ padding-right: 10px; } #iframe-wrapper{ width: -webkit-fill-available; height: -webkit-fill-available; margin:0 305px 0 686px; top:0; } #priview{ width: -webkit-fill-available; height: -webkit-fill-available; background: #fefefe; border: none; box-shadow: 0 0 2px #00000038; } ` document.head.appendChild(style) const grid = document.querySelector('.grid-16-8') const iframe = document.createElement("iframe") const iframeWrapper = document.createElement("div") const trs = document.querySelectorAll('table.olt tr:not(.th)') let prevTr iframeWrapper.id = "iframe-wrapper" iframe.srcdoc = '<style>p{color:#bbb;font-style:italic;font-size:12px;}a{color: #0f959d;text-decoration: none;}a:hover{color:red;}</style><p>/*话题快速预览 © <a href="https://www.douban.com/people/48915223/">铛铛铛铛铛</a>*/</p><p>Tips:<br/>因为豆瓣的原因,在预览里发表回应不会刷新页面,但实际是发表成功的</p>' iframe.id = "priview" iframeWrapper.appendChild(iframe) grid.insertBefore(iframeWrapper, document.querySelector('.extra')) trs.forEach(tr => { tr.onclick = tr.onmouseenter = function () { if (prevTr) prevTr.classList.remove('active') prevTr = tr tr.classList.add('active') iframe.removeAttribute('srcdoc') iframe.src = tr.querySelector('a').href } }) window.addEventListener("scroll", function () { changepos() }) changepos() function changepos() { if (document.documentElement.scrollTop > document.querySelector(".article").offsetTop) { iframeWrapper.style.position = "fixed" } else { iframeWrapper.style.position = "relative" } } } else{ style.innerHTML = ` ::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: #656565; box-shadow: inset 0 0 5px rgba(0,0,0,.1); } ::-webkit-scrollbar-thumb:hover { background: #323232; } ::-webkit-scrollbar-track { background: #ededed; box-shadow: inset 0 0 5px rgba(0,0,0,.1); } ` document.head.appendChild(style) } })();