// ==UserScript== // @name zherop小工具 // @namespace http://tampermonkey.net/ // @version 1.1 // @description 一键无图、隐藏图片、查看源代码 // @author zherop@163.com // @match *://*/* // @connect static.61read.com // @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_download // @grant GM_openInTab // @license AGPL License // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 定义 var menus = [ {"code":"noPic","name":"一键无图","event":"noPic"}, {"code":"hidePic","name":"隐藏图片","event":"hidePic"}, {"code":"viewSource","name":"查看源代码","event":"viewSource"}, {"code":"downloadPng","name":"下载图片","event":"downloadPng","domain":"http://static.61read.com/"}, {"code":"openIframe","name":"访问iframe","event":"openIframe"}, {"code":"checkTargetInIwencai","name":"i问财细选","event":"checkTargetInIwencai","domain":"https?://www.iwencai.com/"} ] // 菜单样式 function menuStyle() { return ` ` } // 创建菜单DOM function createMenuDom() { var html = '
' menus.forEach(item => { var regexObject = new RegExp(item.domain); if(!item.domain || item.domain == "*" || regexObject.test(window.location.href)) { html += `
${item.name}
` } }) html += '
' return html; } // 菜单事件 // 一键无图 function noPic(){ $("img").remove(); $("svg").remove(); } // 隐藏图片 function hidePic(){ $("img").hide(); $("svg").hide(); } // 查看源代码 function viewSource() { GM_openInTab('view-source:' + window.location.href) } // 下载图片 function downloadPng() { var currentHref = window.location.href if(currentHref.startsWith('http://static.61read.com/')) { var baseURL = currentHref.substr(0,currentHref.lastIndexOf('/')) var xmlFile = unsafeWindow.xmlFile var pageFile = unsafeWindow.pageFile GM_xmlhttpRequest({ method: "GET", url: baseURL + '/'+ pageFile + xmlFile, headers: { "Content-Type": "application/xml" }, onload: function(response) { var responseXML = response.responseXML var items = responseXML.getElementsByTagName('item') for(var i=0;i 0) { name = path.substring(path.lastIndexOf('/') + 1) } download(imageURL,name); } } }); } else { } } function download(filePath,name){ fetch(filePath).then(res => res.blob()).then(blob => { const a = document.createElement('a'); document.body.appendChild(a) a.style.display = 'none' // 使用获取到的blob对象创建的url const url = window.URL.createObjectURL(blob); a.href = url; // 指定下载的文件名 a.download = name; a.click(); document.body.removeChild(a) // 移除blob对象的url window.URL.revokeObjectURL(url); }); } function download2(url,name) { GM_download({ url: url, onerror: function (error) { console.log(error) }, onprogress: (pro) => { console.log(pro.loaded) //文件加载量 console.log(pro.totalSize) //文件总大小 }, ontimeout: () => { //如果此下载由于超时而失败,则要执行的回调 }, onload: () => { //如果此下载完成,则要执行的回调 } }) } // 打开iframe function openIframe() { if(document.getElementsByTagName("iframe").length > 0){ window.open(document.getElementsByTagName("iframe")[0].src) } else { console.log('不存在iframe') } } function copyText(text) { if($('#zp-copy').length <= 0) { $("body").append('') } $('#zp-copy').text(text).show(); var ele = document.getElementById("zp-copy"); ele.select(); document.execCommand('copy', false, null); $('#zp-copy').hide(); alert('已复制到剪切板!'); } function checkTargetInIwencai() { console.log('checkTarget'); if(window.location.href.startsWith("http://www.iwencai.com/")) { var trs = $(".iwc-table-scroll").find("tr"); var data = [] for(var i=0;i= 20 && rt >= 20) { selected = true; } else { selected = false; } // 连续5年的平均净利润现金含量高于100%的 var ct = (parseFloat(obj.c1) + parseFloat(obj.c2) + parseFloat(obj.c3) + parseFloat(obj.c4) + parseFloat(obj.c5))/5; obj.ct = ct; if(ct >= 100) { selected = selected && true; } else { selected = selected && false; } // 连续5年的毛利率中,平均值并且最近1年的数值高于40%的 var mf = parseFloat(obj.m1); var mt = (parseFloat(obj.m1) + parseFloat(obj.m2) + parseFloat(obj.m3) + parseFloat(obj.m4) + parseFloat(obj.m5))/5; obj.mt = mt; if(mt >= 40 && mf >= 40) { selected = selected && true; } else { selected = selected && false; } if(selected) { selectedData.push(obj); obj.checkbox.click(); } } // 复制选中的结果 var content = ""; for(var index in selectedData){ content += "代码:" + selectedData[index].code + "\n"; content += "名称:" + selectedData[index].name + "\n"; content += "现价:" + selectedData[index].price + "\n"; content += "连续5年的ROE平均值%:" + selectedData[index].rt.toFixed(2) + "\n"; content += "连续5年的净利润现金含量平均值%:" + selectedData[index].ct.toFixed(2) + "\n"; content += "连续5年的毛利率平均值%:" + selectedData[index].mt.toFixed(2) + "\n"; content += "--------------------------------------\n"; } copyText(content); } } // 处理部分站点的样式 function handleSite() { if(window.location.href.startsWith("https://xueqiu.com")) { // 雪球 $('link[rel="shortcut icon"]').attr("href","https://www.efunds.com.cn/assets/images/favicon.ico") $(".nav__logo").css('background','url("https://cdn.efunds.com.cn/owch/upload/resources/image/2021/11/04/1040.png") no-repeat 50%'); $(".nav__logo").css('background-size','100% 100%'); $(".nav").css('background-color','#bebebe'); $(".nav__logo").attr("href","https://www.efunds.com.cn/") $(".nav__rt").hide() $(".zp-menu").hide(); } } $(function(){ $("head").append(menuStyle()) $("body").append(createMenuDom()) if(document.getElementsByTagName("iframe").length == 0){ $(".zp-menu-item[type='openIframe']").hide() } // 菜单绑定事件 $("#zp-menu .zp-menu-item").click(function(){ var opType = $(this).attr("type") var currentMenu = menus.find(item => item.code===opType) if(currentMenu) { eval(currentMenu.event + "()") } }) // 处理网站 handleSite(); }) })();