Untitled
unknown
javascript
2 years ago
1.5 kB
12
Indexable
// ==UserScript==
// @name KG_MainChatReload
// @namespace http://tampermonkey.net/
// @version 2024-01-02
// @description Fix the issue with the chat lost connection by reloading the page
// @author Patcher
// @match *://klavogonki.ru/g*
// @icon https://www.google.com/s2/favicons?sz=64&domain=klavogonki.ru
// @grant none
// ==/UserScript==
(function() {
// Select the input element
var inputElement = document.querySelector('.text');
// Array to store logs
var logsArray = JSON.parse(localStorage.getItem('lostChatConnections')) || [];
// Function to add a log entry with the current date
const addLog = () => {
const currentDate = new Date();
logsArray.push(currentDate);
localStorage.setItem('lostChatConnections', JSON.stringify(logsArray));
}
// Use MutationObserver to observe changes to the attributes of the input element
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
// Check if 'disabled' attribute is present
if (inputElement.disabled) {
// Add log entry
addLog();
// Set a timeout before reload
setTimeout(() => location.reload(), 1000);
}
});
});
// Configure and start the MutationObserver
const observerConfig = { attributes: true };
observer.observe(inputElement, observerConfig);
})();Editor is loading...
Leave a Comment