mirror of https://github.com/helloxz/imgurl.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.5 KiB
69 lines
2.5 KiB
6 years ago
|
// ==UserScript==
|
||
|
// @name ImgURL上传脚本
|
||
|
// @namespace https://imgurl.org/
|
||
|
// @version 0.1
|
||
|
// @description ImgURL快捷上传工具
|
||
|
// @author xiaoz.me
|
||
|
// @match http://*/*
|
||
|
// @match https://*/*
|
||
|
// @license GPL
|
||
|
// @grant none
|
||
|
// ==/UserScript==
|
||
|
|
||
|
(function() {
|
||
|
'use strict';
|
||
|
|
||
|
//定义一个全局弹出层
|
||
|
window.layerstart = '<div id = "layer" style = "box-shadow: 1px 1px 2px #888888;border-radius:5px;top:0em;left:0;width:1280px;height:720px;background-color:#FFFFFF;position:fixed;z-index:999;display:none;border:1px solid #d2d2d2">';
|
||
|
layerstart += '<div style="text-align:right;padding:0.8em;border-bottom:1px solid #d2d2d2;"><a href="javascript:;" onclick="closelayer()" style="color:#FFFFFF;background-color:#FF5722;width:80px;text-align:center;padding:0.5em;border-radius:2px;padding-left:1em;padding-right:1em;">关闭</a></div>';
|
||
|
window.layerend = '</div>';
|
||
|
|
||
|
//让层居中显示
|
||
|
window.layerCenter = function(){
|
||
|
var bwidth = window.screen.availWidth;
|
||
|
var bheight = window.screen.availHeight;
|
||
|
var layertop = (bheight - 720) / 2;
|
||
|
var layerleft = (bwidth - 1280) / 2;
|
||
|
|
||
|
//改变css
|
||
|
$("#layer").css({"top":layertop,"left":layerleft});
|
||
|
}
|
||
|
//创建一个遮罩层
|
||
|
window.keepout = function(){
|
||
|
var fade = '<div id = "fade" style = "width:100%;height:100%;background:rgba(0, 0, 0, 0.5);position: fixed;left: 0;top: 0;z-index: 99;" onclick = "closelayer()"></div>';
|
||
|
$("body").append(fade);
|
||
|
}
|
||
|
|
||
|
//关闭层
|
||
|
window.closelayer = function(){
|
||
|
$("#layer").hide();
|
||
|
//showSidebar();
|
||
|
$("#layer").remove();
|
||
|
$("#fade").remove();
|
||
|
}
|
||
|
|
||
|
//创建一个显示按钮
|
||
|
function imgurl(){
|
||
|
//var imgButton = layerstart;
|
||
|
//imgButton += '<iframe src = "http://localhost/imgurl/miniup.html" width="100%" height="660px" frameborder="0"></iframe>';
|
||
|
//imgButton += layerend;
|
||
|
//$("body").append();
|
||
|
$("body").append('<div id = "imgbtn" style = "position:fixed;right:1em;bottom:1em;z-index:88;cursor:pointer;" onclick = "showImgurl()"><img src = "https://libs.xiaoz.top/material/image.png" width = "36px" height = "36px" /></div>');
|
||
|
}
|
||
|
//显示上传按钮
|
||
|
window.showImgurl = function(){
|
||
|
var up = layerstart;
|
||
|
up += '<iframe src = "https://imgurl.org/miniup.html" width="100%" height="660px" frameborder="0"></iframe>';
|
||
|
up += layerend;
|
||
|
$("body").append(up);
|
||
|
|
||
|
$("#layer").show();
|
||
|
|
||
|
//显示遮罩
|
||
|
keepout();
|
||
|
//居中显示层
|
||
|
layerCenter();
|
||
|
}
|
||
|
|
||
|
imgurl();
|
||
|
})();
|