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

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

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

您需要先安装一个扩展,例如 篡改猴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.5
// @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 
// ==/UserScript==
var div = $("<div id='preview-a'></div>"),
    iframe = $("<iframe id='link' name='link' src='' title='link' ></iframe>"),
    p = $("<p title='点击拖动,移动过程鼠标不要离开此按钮,如果出现异常,点击一次此按钮即可' class='move'></p><p title='关闭'>×</p>"),
    style = $("<style>.move::before{content: '▞'}</style>");
$('head').append(style);
var parentDiv = div.append(iframe).append(p);
var timer,istrue;
$("a").mouseover(function(e){

    //不想讓預覽頁被自動點擊就把預覽頁面網址加入判斷
    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;
    }

    var athis = $(this)[0];

    timer = setTimeout(function(){

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

        $("#preview-a").mouseout(function()
        {
            $("#preview-a").hide();
        })
        //移除不想要的網站元素
        $("#link").on("load", () => {
            $(window.frames["link"].document).find("#toptb").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("#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*='bar']").remove();
            $(window.frames["link"].document).find("div[class*='bar']").remove();
            $(window.frames["link"].document).find("#foruminfo").remove();
            //$(window.frames["link"].document).find("div[id*='head']").remove();
            //$(window.frames["link"].document).find("tbody").first().remove();
            //$(window.frames["link"].document).find(".pls").remove();
        })
    },850); //修改這裡可讓自動點擊的時間延遲
});

$("a").mouseout(function(){
    clearTimeout(timer);
    });

$("body").on('click','#preview-a p:eq(1)',function(){
    $("#preview-a").hide();
    //istrue = false;
})

$('body').on('mousedown','#preview-a .move',function(){
    $(document).on('mousemove',function(e = window.event){
        moveGo(e);
    })
    function moveGo(e){
        var pL = $("#preview-a").offset().left,
            pT = $("#preview-a").offset().top,
            mL = $('.move').offset().left,
            mT = $('.move').offset().top,
            disW = mL - pL,
            disH = mT - pT;
        $("#preview-a").css({
            'left': e.clientX - disW - 15,
            'top': e.clientY - disH -15
        })
    }

    $(document).on('mouseup', function(){
        moveGo = ()=>{return;}
    })

})

function sty(){
    //調整預覽頁的介面
    $("#preview-a").css({
        'background': '#fff',
        'position': 'fixed',
        'width': '85%',
        '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%',
    });
    /*$("#preview-a p").css({
        'width': '30px',
        'height': '30px',
        'line-height': '29px',
        'background': 'red',
        'border-radius': '50%',
        'color':'#ffffff',
        'font-size':'20px',
        'text-align':'center',
        'cursor': 'pointer',
        'position':'absolute',
        'top':'48%',
        'left':10,
        'z-index': '999999'
    });
    $(".move").css({
        'line-height': '28px',
        'top': '40%',
        'font-size': '14px',
        'cursor': 'move'
    });*/
}