Greasy Fork is available in English.
浏览一些隐藏图片,放大预览,添加了翻页按键
当前为
// ==UserScript==
// @name Yande.re 浏览隐藏图片,放大预览,添加翻页按键
// @namespace none
// @version 0.1
// @description 浏览一些隐藏图片,放大预览,添加了翻页按键
// @author Joker
// @match https://yande.re/post*
// @grant none
// @require https://cdn.bootcss.com/jquery/3.4.1/jquery.slim.min.js
// ==/UserScript==
jQuery.noConflict();
jQuery(function(){
var $ = jQuery;
var zoombox = '<div id="zoombox" style="position: fixed; top:0; left:0; width:300px; height:100%;"></div>';
var $zoombox = $(zoombox);
$zoombox.hide();
$("body").append($zoombox);
addGlobalStyle('#zoombox img{width:100%; height:auto}');
//显示隐藏图片
showHiddenImage();
//左右翻页
addKey();
// 添加鼠标放大预览
addMouseZoomPreview();
//添加全局css
function addGlobalStyle(css) {
var $head, $style;
$head = $('head');
$style = $("<style></style>");
$style.html(css);
$head.append($style);
}
//添加按键
function addKey(){
$(document).keydown(function(e){
//console.log("keydown")
if(e.keyCode == 37){
$('a.previous_page')[0].click();
} else if(e.keyCode == 39){
$('a.next_page')[0].click();
}
});
}
//显示隐藏图片
function showHiddenImage(){
var hideClassName = "javascript-hide";
var boxShadow = "0px 0px 20px 3px #c1de4c";
var $allPostLi = $("#post-list-posts > li");
$.each( $allPostLi, function(index, item){
var $item = $(item);
if ($item.hasClass(hideClassName)) {
//console.log($item)
// 加上阴影标识
$item.removeClass(hideClassName);
var $inner = $item.children(".inner");
$inner.css({
boxShadow:boxShadow
});
// 调整顺序到最开始
$item.prependTo($("#post-list-posts"));
}
});
}
// 添加鼠标放大预览
function addMouseZoomPreview(){
var $allPostLi = $("#post-list-posts > li");
$.each( $allPostLi, function(index, item){
var $item = $(item);
$item.hover(function(e){
var $self = $(this);
var s = $self.find(".inner>a");
//console.log(s.html())
$zoombox.show();
$zoombox.append(s.html());
}, function(e){
var $self = $(this);
$zoombox.hide();
$zoombox.html("");
})
});
}
});