// ==UserScript== // @name zherop小工具 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 一键无图、隐藏图片、查看源代码 // @author zherop@163.com // @match *://*/* // @require //cdn.staticfile.org/jquery/3.3.1/jquery.min.js // @grant none // @license AGPL License // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 菜单样式 function menuStyle() { return ` ` } // 创建DOM function createDom() { return `
`; } function copyText(str) { $('#zp-copy').text(str).show(); var ele = document.getElementById("zp-copy"); ele.select(); document.execCommand('copy', false, null); $('#zp-copy').hide(); alert('复制链接成功!'); } $(function(){ $("head").append(menuStyle()) $("body").append(createDom()) // 菜单绑定事件 $("#zp-menu .zp-menu-item").click(function(){ var opType = $(this).attr("type") if(opType === 'noPic') { $("img").remove(); $("svg").remove(); }else if(opType === 'hidePic'){ $("img").hide(); $("svg").hide(); }else if(opType === 'viewSource'){ copyText('view-source:' + window.location.href) } }) }) })();