預覽網頁(改),懸停0.8s出現框架頁預覽(preview web page)

滑鼠停在連結上會彈出個框架頁,讓你不用切換頁面就能看內容,關閉預覽頁也只要將滑鼠移出預覽頁範圍內即可,完全不用點擊

当前为 2021-08-18 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         預覽網頁(改),懸停0.8s出現框架頁預覽(preview web page)
// @namespace
// @version      1.3
// @description  滑鼠停在連結上會彈出個框架頁,讓你不用切換頁面就能看內容,關閉預覽頁也只要將滑鼠移出預覽頁範圍內即可,完全不用點擊
// @author       kater4343587
// @include      http://*
// @include      https://*
// @exclude     */forum.php?mod=viewthread&tid=*
// @exclude    *.php?tid=*
// @require      https://code.jquery.com/jquery-3.3.1.min.js
// @require      https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant        GM_getValue
// @grant        GM_setValue
// @namespace
// @namespace
// @namespace
// @namespace
// @namespace 
// ==/UserScript==
if (localStorage.admercyblocks) {
  localStorage.admercyblocks = Infinity;
}
var div = $("<div id='preview-a'></div>"),
    iframe = $("<iframe id='link' name='link' src='' title='link' ></iframe>"),
    parentDiv = div.append(iframe),
    timer;

$(document).ready(function(){
    $(document).on("mouseover", "a:not([href*='.jpg'],[href*='.png'],[href='#'],[href*='javascript'])", function () {
        var target=$(this).attr("href");
        if(target!=undefined){
            //不想讓預覽頁再彈出預覽頁就把預覽頁面網址加入判斷
            if(window.location.href.match(/acg.rip\/t/))
            {
                return;
            }
            if(window.location.href.match(/bbs-tw.com\/cgi-bin\/bbs\/postshow/))
            {
                return;
            }
            if(window.location.href.match(/www.gtloli.live\/t/))
            {
                return;
            }
            if(window.location.href.match(/keylol.com\/t/))
            {
                return;
            }
            if(window.location.href.match(/forum.gamer.com.tw\/C.php/))
            {
                return;
            }
            if(window.location.href.match(/thread-/))
            {
                return;
            }
            if(window.location.href.match(/tid=/))
            {
                return;
            }
            if(window.location.href.match(/tid-/))
            {
                return;
            }
            if(window.location.href.match(/showthread/))
            {
                return;
            }
            if(window.location.href.match(/kater.me\/d/))
            {
                return;
            }
            if(window.location.href.match(/tieba.baidu.com\/p/))
            {
                return;
            }
            if(window.location.href.match(/topics\/view/))
            {
                return;
            }

            $('body').append(parentDiv);
                sty();
                $('#link').attr('src',`${target}`);

            if(window.location.href.match(/chinese.engadget.com/))
            {
                $("#link").load(target); //部分網頁能支援但效果不好
            }

            $("#preview-a").hide();
            clearTimeout(timer);
            timer = setTimeout(function(){

                $("#preview-a").show();

                $("#preview-a").mouseout(function(){
                    $("#preview-a").hide();
                    clearTimeout(timer);
                })
                //移除不想要的網站元素,加快預覽頁的載入速度
                $("#link").ready(function(){
                    $("#link").contents().find("#toptb").remove();
                    $("#link").contents().find("div[id*='logo']").remove();
                    $("#link").contents().find("div[class*='logo']").remove();
                    $("#link").contents().find("img[src*='logo']").remove();
                    $("#link").contents().find("#pt").remove();
                    $("#link").contents().find(".toptb").remove();
                    $("#link").contents().find(".top").remove();
                    $("#link").contents().find(".hdc.cl").remove();
                    $("#link").contents().find("#hdc.cl").remove();
                    $("#link").contents().find("#top_login").remove();
                    $("#link").contents().find("#hd").remove();
                    $("#link").contents().find("header[id*='bar']").remove();
                    $("#link").contents().find("header[id*='top']").remove();
                    $("#link").contents().find("#head").remove();
                    $("#link").contents().find("#header").remove();
                    $("#link").contents().find("div[id*='topbar']").remove();
                    $("#link").contents().find("div[class*='topbar']").remove();
                    $("#link").contents().find("div[id*='search']").remove();
                    $("#link").contents().find("div[class*='search']").remove();
                    $("#link").contents().find("#foruminfo").remove();
                    $("#link").contents().find(".error").remove();
                    $("#link").contents().find("#header-inner").remove();
                    $("#link").contents().find("#bd").remove();
                    $("#link").contents().find("#navbar").remove();
                    $("#link").contents().find("div[id*='navlist']").remove();
                    $("#link").contents().find("div[class*='navlist']").remove();
                    $("#link").contents().find("div[id*='global-nav']").remove();
                    $("#link").contents().find("div[class*='global-nav']").remove();
                    $("#link").contents().find("div[id*='navbar']").remove();
                    $("#link").contents().find("div[class*='navbar']").remove();
                    $("#link").contents().find("div[id*='nvbd']").remove();
                    $("#link").contents().find("div[class*='nvbd']").remove();
                    $("#link").contents().find("div[id*='hornbox']").remove();
                    $("#link").contents().find("#welcome_mask").remove();
                    $("#link").contents().find("#welcome_present").remove();
                })
                //框架頁載入時漏掉的補清..
                $("#link").on("load", () => {
                    $("#link").contents().find("div[id*='hornbox']").remove();
                    $("#link").contents().find("#foruminfo").remove();
                    $("#link").contents().find("#hd").remove();
                    $("#link").contents().find("#toptb").remove();
                    $("#link").contents().find(".hdc.cl").remove();
                    $("#link").contents().find("#hdc.cl").remove();
                    $("#link").contents().find("#welcome_mask").remove();
                    $("#link").contents().find("#welcome_present").remove();
                    $("#link").contents().find("#wp").css({'filter': 'blur(0px)'});
                    $("#link").contents().find("#nv_forum").css({'overflow': 'auto'});
                })
            },850); //修改這裡可讓預覽頁出現的時間延遲
        }
    });
});
$(document).on("mouseout", "a", function () {
    //$("#preview-a").hide();
    clearTimeout(timer);
    });

function sty(){
    //調整預覽頁的介面,盡量調整到試範影片那樣,體驗比較好
    $("#preview-a").css({
        'background': '#fff',
        'position': 'fixed',
        'width': '106%', //可能需自己調整的參數
        'height': '120%', //可能需自己調整的參數
        'border': '0px solid #f1f1f1',
        'border-radius': '8px',
        'z-index': 9999999,
        'overflow': 'auto',
        'top': '-9%', //可能需自己調整的參數
        'left': '-3%', //可能需自己調整的參數
        'scale':'85%', //預覽頁是否縮放? 調100%就是原封不動的大小
        'display':'none'
    })
    $("#preview-a iframe").css({
        'border': 'none',
        'width': '100%',
        'height': '100%',
    });
}