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

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

当前为 2020-09-07 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         預覽網頁(改),懸停0.8s出現框架頁預覽(preview web page)
// @namespace
// @version      1.0.8.3
// @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(/okfun.org\/thread/))
            {
                return;
            }
            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;
            }

            $('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").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'});
                    $(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("#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': '110%',
        'height': '120%',
        'border': '0px solid #f1f1f1',
        'border-radius': '8px',
        'z-index': 9999999,
        'overflow': 'hidde',
        'top': '-12%',
        'left': '5%',
        'scale':'79%',
        'display':'none'
    })
    $("#preview-a iframe").css({
        'border': 'none',
        'width': '100%',
        'height': '100%',
    });
}