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

在zhchjiang95的代碼基礎上修改,原作者的發布頁:https://greasyfork.org/zh-TW/scripts/372741-%E9%A2%84%E8%A7%88%E7%BD%91%E9%A1%B5-%E6%82%AC%E5%81%9C1-5s%E5%9C%A8%E6%9C%AC%E9%A1%B5%E9%9D%A2%E9%A2%84%E8%A7%88%E5%B0%86%E8%A6%81%E8%B7%B3%E8%BD%AC%E7%9A%84%E7%BD%91%E9%A1%B5,讓你不用點擊連結就能在本頁面預覽內容,關閉預覽頁也只要將滑鼠移出預覽頁範圍內即可,完全不用點擊,雖還有許多已知BUG,但已達到實用化程度

当前为 2020-08-24 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         預覽網頁(改),懸停0.8s出現框架頁預覽(preview web page)
// @namespace    
// @version      1.0.1
// @description  在zhchjiang95的代碼基礎上修改,原作者的發布頁:https://greasyfork.org/zh-TW/scripts/372741-%E9%A2%84%E8%A7%88%E7%BD%91%E9%A1%B5-%E6%82%AC%E5%81%9C1-5s%E5%9C%A8%E6%9C%AC%E9%A1%B5%E9%9D%A2%E9%A2%84%E8%A7%88%E5%B0%86%E8%A6%81%E8%B7%B3%E8%BD%AC%E7%9A%84%E7%BD%91%E9%A1%B5,讓你不用點擊連結就能在本頁面預覽內容,關閉預覽頁也只要將滑鼠移出預覽頁範圍內即可,完全不用點擊,雖還有許多已知BUG,但已達到實用化程度
// @author       kater4343587
// @include      http://*
// @include	     https://*
// @require      https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @match        http://*
// @match        https://*
// @grant        none
// ==/UserScript==
var div = $("<div id='preview-a'></div>"),
    iframe = $("<iframe name='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,lastmove=false;
$("a").attr("target","link");
$("a[onclick*='target']").removeAttr("onclick");
//$("a").removeAttr("onclick");
$("a").removeAttr("onmousedown");
$("a").mouseover(function(){

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

        if(lastmove)
        {
            athis.click();
            $("#preview-a").show();
            return;}
        else{
            $("#preview-a").show();
            $('body').append(parentDiv);
            sty();
            athis.click();
        }


        $("#preview-a").mouseout(function()
        {
            $("#preview-a").hide();
        })

            //istrue = true;
    },800); //修改這裡可讓自動點擊的時間延遲
});

$("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);
    })
    lastmove = true;
    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'
    });*/
}
            //移除不想要的網站元素
            //$("img[src*='logo']").remove();
            $("#toptb").remove();
            $("#pt").remove();
            $(".toptb").remove();
            $(".top").remove();
            $(".hdc cl").remove();
            $("#hdc cl").remove();
            //$(".pls").remove();