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

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

目前為 2020-09-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         預覽網頁(改),懸停0.8s出現框架頁預覽(preview web page)
// @namespace
// @version      1.1.0
// @description  滑鼠停在連結上會彈出個框架頁,讓你不用切換頁面就能看內容,關閉預覽頁也只要將滑鼠移出預覽頁範圍內即可,完全不用點擊
// @author       kater4343587
// @include      http://*
// @include	     https://*
// @exclude	     https://www.91wii.com/forum.php
// @exclude	     https://www.tsdm39.net/forum.php?mod=viewthread&tid=*
// @require      https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @match        http://*
// @match        https://*
// @grant        none
// @namespace
// @namespace
// @namespace 
// ==/UserScript==
$(".announcement__container.linked").remove();
//$("a[onclick*='target']").removeAttr("onclick");
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", function () {
        var target=$(this).attr("href");
        if(target!=undefined){
            //不想讓預覽頁被自動點擊就把預覽頁面網址加入判斷

            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(/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}`)

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

            timer = setTimeout(function(){

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

                $("#preview-a").mouseout(function(){
                    $("#preview-a").hide();
                    clearTimeout(timer);
                })
                //移除不想要的網站元素
                $("#link").ready(function(){
                    $(window.frames["link"].document).find("#toptb").remove();
                    $(window.frames["link"].document).find("div[id*='logo']").remove();
                    $(window.frames["link"].document).find("div[class*='logo']").remove();
                    $(window.frames["link"].document).find("img[src*='logo']").remove();
                    $(window.frames["link"].document).find("#pt").remove();
                    $(window.frames["link"].document).find(".toptb").remove();
                    $(window.frames["link"].document).find(".top").remove();
                    $(window.frames["link"].document).find(".hdc.cl").remove();
                    $(window.frames["link"].document).find("#hdc.cl").remove();
                    $(window.frames["link"].document).find("#top_login").remove();
                    $(window.frames["link"].document).find("#hd").remove();
                    $(window.frames["link"].document).find("header[id*='bar']").remove();
                    $(window.frames["link"].document).find("header[id*='top']").remove();
                    $(window.frames["link"].document).find("#head").remove();
                    $(window.frames["link"].document).find("#header").remove();
                    $(window.frames["link"].document).find("div[id*='topbar']").remove();
                    $(window.frames["link"].document).find("div[class*='topbar']").remove();
                    $(window.frames["link"].document).find("div[id*='search']").remove();
                    $(window.frames["link"].document).find("div[class*='search']").remove();
                    $(window.frames["link"].document).find("#foruminfo").remove();
                    $(window.frames["link"].document).find(".error").remove();
                    $(window.frames["link"].document).find("#header-inner").remove();
                    $(window.frames["link"].document).find("#bd").remove();
                    $(window.frames["link"].document).find("#navbar").remove();
                    $(window.frames["link"].document).find("div[id*='navlist']").remove();
                    $(window.frames["link"].document).find("div[class*='navlist']").remove();
                    $(window.frames["link"].document).find("div[id*='global-nav']").remove();
                    $(window.frames["link"].document).find("div[class*='global-nav']").remove();
                    $(window.frames["link"].document).find("div[id*='navbar']").remove();
                    $(window.frames["link"].document).find("div[class*='navbar']").remove();
                    $(window.frames["link"].document).find("div[id*='nvbd']").remove();
                    $(window.frames["link"].document).find("div[class*='nvbd']").remove();
                    $(window.frames["link"].document).find("div[id*='hornbox']").remove();
                    //$(window.frames["link"].document).find(".pls").remove();
                    //$(window.frames["link"].document).find("a[href*='.jpg']").removeAttr("href"); //防止圖片放大
                })
                $("#link").on("load", () => {
                $(window.frames["link"].document).find("#welcome_mask").remove();
                    $(window.frames["link"].document).find("#welcome_present").remove();
                    $(window.frames["link"].document).find("#wp").css({'filter': 'blur(0px)'});
                    $(window.frames["link"].document).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': '-12%',
        'left': '5%',
        'scale':'79%',
        'display':'none'
    })
    $("#preview-a iframe").css({
        'border': 'none',
        'width': '100%',
        'height': '100%',
    });
}