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

讓你不用點擊連結就能在本頁面預覽內容,關閉預覽頁也只要將滑鼠移出預覽頁範圍內即可,完全不用點擊

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         預覽網頁(改),懸停0.8s出現框架頁預覽(preview web page)
// @namespace
// @version      1.0.7.1
// @description  讓你不用點擊連結就能在本頁面預覽內容,關閉預覽頁也只要將滑鼠移出預覽頁範圍內即可,完全不用點擊
// @author       kater4343587
// @include      http://*
// @include	     https://*
// @exclude	     https://www.91wii.com/forum.php
// @require      https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @match        http://*
// @match        https://*
// @grant        none
// @namespace
// @namespace 
// ==/UserScript==
$(".announcement__container.linked").remove();
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.91wii.com\/thread/))
            {
                return;
            }
            if(window.location.href.match(/kater.me\/d/))
            {
                return;
            }
            if(window.location.href.match(/www.backpackers.com.tw\/forum\/showthread.php/))
            {
                return;
            }
            if(window.location.href.match(/tieba.baidu.com\/p/))
            {
                return;
            }
            if(window.location.href.match(/share.dmhy.org\/topics\/view/))
            {
                return;
            }
            if(window.location.href.match(/www.52pojie.cn\/thread/))
            {
                return;
            }

            timer = setTimeout(function(){

                $("#preview-a").show();
                $('body').append(parentDiv);
                sty();
                $('#link').attr('src',`${target}`)

                $("#preview-a").mouseout(function(){
                    $("#preview-a").hide();
                    clearTimeout(timer);
                })
                //移除不想要的網站元素
                $("#link").on("load", () => {
                    $(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(".width.border").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("#top").remove(); //部分網頁有問題
                    //$(window.frames["link"].document).find("div[class*='head']").remove();
                    //$(window.frames["link"].document).find("div[id*='head']").remove();
                    //$(window.frames["link"].document).find("div[id*='nav']").remove();
                    //$(window.frames["link"].document).find("div[class*='nav']").remove();
                    //$(window.frames["link"].document).find("header[id*='head']").remove();
                    //$(window.frames["link"].document).find("header[class*='head']").remove();
                })
            },850); //修改這裡可讓預覽頁出現的時間延遲
        }
    });
});

$(document).on("mouseout", "a", function () {
    //$("#preview-a").hide();
    clearTimeout(timer);
    });

function sty(){
    //調整預覽頁的介面
    $("#preview-a").css({
        'background': '#fff',
        'position': 'fixed',
        'width': '80%',
        'height': '100%',
        'border': '0px solid #f1f1f1',
        'border-radius': '8px',
        'z-index': 9999999,
        'overflow': 'hidden',
        'top': '0%',
        'left': '29%'
    })
    $("#preview-a iframe").css({
        'border': 'none',
        'width': '100%',
        'height': '100%',
    });
}