您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds live example button, with styling.
当前为
// ==UserScript== // @name _open/close all Sections of americandragon.com // @description Adds live example button, with styling. // @match *://americandragon.com/* // @match *://www.americandragon.com/* // @grant GM_addStyle // @version 1.0 // @namespace https://wu-wei.net // @license MIT // ==/UserScript== /*--- Create a button in a container div. It will be styled and positioned with CSS. */ var targetE = document.querySelector('.p7TBMtext'); console.log(targetE); var foldedE = document.querySelectorAll("#maincontent [id^='p7ABt']"); console.log(foldedE); // var myEvent = document.createEvent('Event'); // event.initEvent('my-custom-event', true, true); var evtNew = document.createEvent("MouseEvents"); evtNew.initEvent("click", true, true); var zNode = document.createElement ('li'); zNode.innerHTML = '<button id="p7TBMt09" type="button">' + 'open\/close all sections</button>' ; zNode.setAttribute ('id', 'myContainer'); //document.body.appendChild(zNode); targetE.appendChild(zNode); targetE.insertBefore(zNode, targetE.firstChild); //--- Activate the newly added button. document.getElementById ("p7TBMt09").addEventListener ( "click", ButtonClickAction, false ); function ButtonClickAction (zEvent) { /*--- For our dummy action, we'll just add a line of text to the top of the screen. */ for(myE of foldedE){ console.log(myE); myE.dispatchEvent(evtNew); } } //--- Style our newly added elements using CSS. function GM_addStyle(css) { const style = document.getElementById("GM_addStyleBy8626") || (function() { const style = document.createElement('style'); style.type = 'text/css'; style.id = "GM_addStyleBy8626"; document.head.appendChild(style); return style; })(); const sheet = style.sheet; sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length); } GM_addStyle ( ` #myContainer { position: absolute; top: 0; left: 0; font-size: 20px; background: orange; border: 3px outset black; margin: 5px; opacity: 0.9; z-index: 1100; padding: 5px 20px; } #p7TBMt09 { cursor: pointer; } #myContainer p { color: red; background: white; } ` );