Last active
October 20, 2023 04:54
-
-
Save leavyli/99999873c3d79aa17904fdafcf648a08 to your computer and use it in GitHub Desktop.
油猴脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name aicompasspro的自动循环发音 | |
| // @namespace ... | |
| // @version 0.1.0 | |
| // @description aicompasspro的自动循环发音 | |
| // @author You | |
| // @match https://m.openlanguage.com/* | |
| // @match https://www.aicompasspro.com/* | |
| // @grant none | |
| // @run-at document-idle | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| if (window === window.top) { | |
| window.addEventListener('message', e => { | |
| if (e.data.myMessage && e.data.myMessage.command === 'readyAutoPlay') { | |
| e.source.postMessage({ | |
| myMessage: { | |
| command: 'sendAutoPlay', | |
| data: document.title | |
| } | |
| }, '*'); | |
| } | |
| }); | |
| } else { | |
| window.addEventListener('message', e => { | |
| if (e.data.myMessage && e.data.myMessage.command === 'sendAutoPlay') { | |
| // 获取类名为'myClass'的第一个元素 | |
| var element = window.document.querySelector(".icon-loop"); | |
| // 创建一个点击事件 | |
| var event = new MouseEvent('click', { | |
| 'view': window, | |
| 'bubbles': true, | |
| 'cancelable': true | |
| }); | |
| // 触发点击事件 | |
| element.dispatchEvent(event); | |
| } | |
| }); | |
| window.addEventListener('load', function (event) { | |
| console.log("load.....") | |
| // 您的代码在这里 | |
| var interval = setInterval(function () { | |
| var element = window.document.querySelector(".icon-loop"); | |
| if (element != null) { | |
| window.top.postMessage({ | |
| myMessage: { | |
| command: 'readyAutoPlay' | |
| } | |
| }, '*'); | |
| clearInterval(interval); | |
| } | |
| }, 400); | |
| }); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment