Skip to content

Instantly share code, notes, and snippets.

@leavyli
Last active October 20, 2023 04:54
Show Gist options
  • Select an option

  • Save leavyli/99999873c3d79aa17904fdafcf648a08 to your computer and use it in GitHub Desktop.

Select an option

Save leavyli/99999873c3d79aa17904fdafcf648a08 to your computer and use it in GitHub Desktop.
油猴脚本
// ==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