加速你的體驗,不用點擊滑鼠就能預覽連結的內容
目前為
// ==UserScript==
// @name 預覽網頁(改),懸停0.8s出現框架頁預覽(preview web page)
// @namespace
// @version 1.0.3
// @description 加速你的體驗,不用點擊滑鼠就能預覽連結的內容
// @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();