v2ex 免跳转浏览

在 v2ex 主页面显示鼠标悬停内容

目前為 2022-04-14 提交的版本,檢視 最新版本

// ==UserScript==
// @name        v2ex 免跳转浏览
// @namespace   ThomasKara
// @run-at document-end
// @include     http*://*v2ex.com/*
// @version     0.0.3
// @description 在 v2ex 主页面显示鼠标悬停内容
// ==/UserScript==
function insertAfter(newNode, existingNode) {
    existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);
}

(function () {
    'use strict';
    var box=document.querySelector("#Main .box");
    var l=box.querySelectorAll("#Main .box .cell.item");
    var ifrm=box.querySelector("iframe");

    if (l.length){
        document.querySelector("#Rightbar").style.display="none";
        if (!ifrm){
            ifrm=document.createElement("iframe");
            ifrm.style="width: 92vw;height: 80vh;border: 1px solid;z-index: 1;";
            var blocker=document.createElement("div");
            blocker.style="position: fixed; bottom: 0px; height: 7vh; width: 100vw;";
            document.body.appendChild(blocker);
        }
        for (var i=0;i<l.length;i++){
            var a=l[i].querySelector(".item_title a");
            if (a){
                let current=l[i];
                let a=current.querySelector(".item_title a");
                a.onmouseenter=()=>{
                    if (ifrm.src!=a.href){
                        ifrm.src=a.href;
                        insertAfter(ifrm, current);
                        window.scrollTo(0, current.getBoundingClientRect().top + document.documentElement.scrollTop)
                        ifrm.onload=()=>{
                            ifrm.contentWindow.document.querySelector("#reply-box").style.display="none";
                            ifrm.contentWindow.document.querySelector("#Bottom").style.display="none";
                        };
                    }
                };
            }
        }
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址