$lesson_pr_ + lesson_idtext = 90 油猴监听是否大于等90
To listen for changes to the text of an element with a class name that matches a specific pattern using Tampermonkey, you can use the MutationObserver API. Here's an example code snippet:
// Create a new MutationObserver instance
const observer = new MutationObserver((mutationsList, observer) => {
// Iterate through each mutation
for (const mutation of mutationsList) {
// Check if the mutation is a text change
if (mutation.type === 'characterData' || mutation.type === 'childList') {
// Get the text value of the element
const text = $('.lesson_pr_' + lesson_id).text();
// Check if the text value is greater than or equal to 90
if (parseInt(text) >= 90) {
// Do something here
console.log('Text is greater than or equal to 90');
}
}
}
});
// Select the target element to observe
const targetElement = document.querySelector('.lesson_pr_' + lesson_id);
// Start observing changes to the target element
observer.observe(targetElement, { characterData: true, childList: true });
Make sure to replace 'lesson_pr_' + lesson_id with the correct class name pattern that matches the element you want to observe. Also, adjust the code within the if statement to perform the desired action when the text value is greater than or equal to 90
原文地址: https://www.cveoy.top/t/topic/hZDK 著作权归作者所有。请勿转载和采集!