Created
June 6, 2023 07:29
-
-
Save IlyaZha/cd90efcdddeee995708c6896aad460b8 to your computer and use it in GitHub Desktop.
tlscontact JS
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
const audio = new Audio(); | |
// Set the source of the audio file | |
audio.src = 'http://commondatastorage.googleapis.com/codeskulptor-assets/week7-brrring.m4a'; | |
const audio2 = new Audio(); | |
// Set the source of the audio file | |
audio2.src = 'http://commondatastorage.googleapis.com/codeskulptor-assets/Collision8-Bit.ogg'; | |
function makeAttention() { | |
audio.play(); | |
setTimeout(() => audio2.play(), 1000); | |
} | |
function getBlockElement() { | |
return document.querySelector('#timeTable'); | |
} | |
// Get the DOM block element using the CSS selector | |
const blockElement = getBlockElement(); | |
// Check if the block element exists | |
if (blockElement) { | |
// Convert the DOM block to HTML string | |
const blockHtml = blockElement.outerHTML; | |
if (blockHtml !== localStorage.getItem('savedBlock', blockHtml)) { | |
makeAttention(); | |
} | |
// Save the HTML string to local storage | |
localStorage.setItem('savedBlock', blockHtml); | |
// Create a new mutation observer instance | |
const observer = new MutationObserver((mutations) => { | |
// Handle mutations | |
mutations.forEach((mutation) => { | |
// Perform actions based on the type of mutation | |
// For example, log the mutation type to the console | |
makeAttention(); | |
}); | |
}); | |
// Configure and start the observer | |
const observerConfig = { attributes: true, | |
childList: true, | |
subtree: true, | |
characterData: true }; | |
observer.observe(blockElement, observerConfig); | |
} else { | |
makeAttention(); | |
} | |
function callable() { | |
const blockElement = getBlockElement(); | |
const blockHtml = blockElement.outerHTML; | |
if (blockHtml !== localStorage.getItem('savedBlock', blockHtml)) { | |
makeAttention(); | |
} | |
// Call the function again after 1 second | |
setTimeout(callable, 1000); | |
} | |
// Start the initial call | |
callable(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment