讓你不用點擊連結就能在本頁面預覽內容,關閉預覽頁也只要將滑鼠移出預覽頁範圍內即可,完全不用點擊
当前为
// ==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%',
});
}