您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
链接当前页面打开
当前为
// ==UserScript== // @name 【自用】雪球 // @match https://xueqiu.com/* // @version 2021.09.08 // @author heckles // @description 链接当前页面打开 // @icon https://github.com/favicon.ico // @homepage https://greasyfork.org/zh-CN/scripts/431835-%E8%87%AA%E7%94%A8-%E9%9B%AA%E7%90%83 // @namespace https://greasyfork.org/users/24050 // ==/UserScript== const cusCSS = ` /*减淡其他信息*/ .optional__tb { color:rgba(0,0,0,0.4) !important; } /*自选股名称加粗*/ td a.name { color:rgba(0,0,0,0.65) !important; font-weight: bold !important; } ` function addNewStyle(newStyle) {//增加新样式表 var styleElement = document.getElementById('styles_js'); if (!styleElement) { styleElement = document.createElement('style'); styleElement.type = 'text/css'; styleElement.id = 'styles_js'; document.getElementsByTagName('head')[0].appendChild(styleElement); } styleElement.appendChild(document.createTextNode(newStyle)); } addNewStyle(cusCSS); const cssframe = ` right: 0px; top: -1px; position: fixed; width: 68%; background-color:#fff; z-index:999999; ` const cssnewsfbg = ` top: 0px; left: 0px; position: fixed; width: 100%; background-color:rgba(0,0,0,0.8); z-index:0; ` var newsframe = document.createElement("iframe"); newsframe.name = "newsframeName"; newsframe.id = "newss"; newsframe.setAttribute("frameborder", "no"); var newsfbg = document.createElement("div"); newsfbg.id = "newsfbg"; document.body.appendChild(newsfbg); newsfbg.appendChild(newsframe); if (window.location.href.indexOf("xueqiu.com/S") < 0) { var WaitXXX = setInterval(function () { //间隔执行 if (document.querySelector("td .name")) { clearInterval(WaitXXX); StartJsIndex(); dvdelne(); layout(); } }, 1000); //间隔时间,毫秒 }else{ StartJsGp(); } function layout() { //var targ = document.querySelector("a[innerHTML='发帖']"); //没法用innerHTML的内容来queryselect,因为目标元素的所有父元素都包含这个内容 //var targ = document.querySelector(".nav__btn--longtext a[href='javascript:;']"); //这样倒是可以 var abr = document.createElement("button"); abr.style.cssText ="margin:2px 0px 2px 12px;width:64px;height:28px;z-index:99999999;font-size:14px;border:0px;background:transparent;color:#fff;"; abr.innerHTML = "切换布局"; document.querySelector("div.signed_container div.nav__lf").appendChild(abr); abr.onclick = function(){ var xx = document.querySelector("div.home__col--rt ul.home__business").style.display; switch (xx) { case "block": xx = "none"; break; case "none": xx = "block"; break; default: xx = "none"; } console.log(xx); document.querySelector("div.home__col--rt ul.home__business").style.display = xx; document.querySelector("div.home__col--rt div.info-report-wrap").style.display = xx; }; abr.click();//模拟点击一下 } function dvdelne() { var zichiRowtd = document.querySelector("a[href='/S/SZ159967']").parentNode.parentNode.querySelectorAll("td");//.previousSibling .nextSibling var zhishuRowtd = document.querySelector("a[href='/S/SH000016']").parentNode.parentNode.querySelectorAll("td"); for (var i=0; i<zichiRowtd.length; i++ ){ zichiRowtd[i].style.borderTop = "2px solid rgba(19, 105, 191, 0.8)"; //querySelectorAll选一群,然后一起设置style不行 } for (var i=0; i<zhishuRowtd.length; i++ ){ zhishuRowtd[i].style.borderTop = "2px solid rgba(19, 105, 191, 0.8)"; //querySelectorAll选一群,然后一起设置style不行 } } function StartJsIndex() { console.log("首页"); var container = document.querySelector(".user__container"); //这里的规则需要按网站修改 ◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀ var dir_links1 = "td .name"; //这里的规则需要按网站修改 ◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀ var dir_links2 = ".home__stock-index__item"; //这里的规则需要按网站修改 ◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀ var dir_links3 = "div.stock-hot__container.board table.stock-hot__list.board__list tr td a"; var dir_links4 = "div.today-topic__list li a"; var dir_links5 = ".status-link"; var anchors1 = document.querySelectorAll(dir_links1);// + document.querySelectorAll(dir_links2);直接加不起作用 var anchors2 = document.querySelectorAll(dir_links2); var anchors3 = document.querySelectorAll(dir_links3); var anchors4 = document.querySelectorAll(dir_links4); var anchors5 = document.querySelectorAll(dir_links5); //var anchors5 = document.getElementsByClassName("status-link"); for (var i = 0; i < anchors1.length; i++) { //anchors[i].target = "newsframeName"; anchors1[i].onclick = function () { zkgp(this); return false; }; //添加函数 } for (var i = 0; i < anchors2.length; i++) { anchors2[i].onclick = function () { zkgp(this); return false; }; //添加函数 } for (var i = 0; i < anchors3.length; i++) { anchors3[i].onclick = function () { zkgp(this); return false; }; //添加函数 } for (var i = 0; i < anchors4.length; i++) { anchors4[i].onclick = function () { zkgp(this); return false; }; //添加函数 } for (var i = 0; i < anchors5.length; i++) { anchors5[i].onclick = function () { zkgp(this); return false; }; //添加函数 } var zkgp = function (a) { newsframe.setAttribute("src", a.getAttribute("href")); container.style.marginLeft = "0%"; newsframe.style.cssText = cssframe + "height:100%;"; newsfbg.style.cssText = cssnewsfbg + "height:100%;"; newsfbg.style.zIndex = "999"; newsfbg.onclick = function () { newsfbg.style.width = "0px"; newsframe.style.width = "0px"; container.style.marginLeft = "auto"; newsframe.setAttribute("src", ""); } } } function StartJsGp(){ console.log("详情"); var article = document.querySelector(".container.article__container");//这里的规则需要按网站修改 ◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀◀ var articleBTN = document.querySelector(".status-link"); //articleBTN.target = "newsframeName"; articleBTN.onclick = function () { zkwl(this); return false; }; //添加函数; var zkwl = function (a) { newsframe.setAttribute("src", a.getAttribute("href")); article.style.marginLeft = "10%"; newsframe.style.cssText = cssframe + "height:100%;"; newsfbg.style.cssText = cssnewsfbg + "height:100%;"; newsfbg.style.zIndex = "999"; newsfbg.onclick = function () { newsfbg.style.width = "0px"; newsframe.style.width = "0px"; article.style.marginLeft = "auto"; newsframe.setAttribute("src", ""); } } }