2021.07.04
当前为
// ==UserScript==
// @name 【自用】JPG
// @namespace Violentmonkey Scripts
// @match http*://*/*.jpg
// @grant none
// @version 2021.07.04
// @author heckles
// @description 2021.07.04
// ==/UserScript==
var css_s = document.querySelectorAll("head > link:nth-child(3)");//获取浏览器自带的图片css
css_s[0].href = "";//删了
function drag(obj) { //根据鼠标位置定义图片位置
obj.onmousedown = function(event) { //鼠标被按下
//alert("我动了");
event = event || window.event;
//div的水平偏移量 鼠标.clentX-元素.offsetLeft
//div的垂直偏移量 鼠标.clentY-元素.offsetTop
var ol = event.clientX - obj.offsetLeft;
var ot = event.clientY - obj.offsetTop;
//绑定鼠标移动事件
document.onmousemove = function(event) {
event = event || window.event;
var left = event.clientX - ol;
var top = event.clientY - ot;
obj.style.left = left + "px";
obj.style.top = top + "px";
}
//为document绑定一个鼠标松开事件
document.onmouseup = function() {
//当鼠标松开时,被拖拽元素固定在当前位置
//取消document.onmousemove事件
document.onmousemove = null;
document.onmouseup = null;
//alert("我松手了");
}
return false;
}
}
var pichref = window.location.href;//获取当前网址,也就是图片地址
var imgs = document.getElementsByTagName("img");
var img = imgs[0];//获取默认图片
img.style.cssText= "display:none;height:0px"//隐藏默认图片
var pic_xx = document.createElement("img"); //创建img
document.body.appendChild(pic_xx); //div加到页面最后
pic_xx.setAttribute("Id", "pic_xx_img"); //定ID
pic_xx.src = pichref;
pic_xx.style.cssText = "position:absolute;";
drag(pic_xx);
//grey_bg.onclick = close_prev; //点击关闭
//pic_xx.onclick = full_view; //点击看100%大小