Skip to content

Instantly share code, notes, and snippets.

@maagmirror
Last active October 25, 2023 00:58
Show Gist options
  • Save maagmirror/fb6bc0a9b2b4386c4bcdfc7cb9bb42bb to your computer and use it in GitHub Desktop.
Save maagmirror/fb6bc0a9b2b4386c4bcdfc7cb9bb42bb to your computer and use it in GitHub Desktop.
script para sacar el molesto 1 cuando no tenes notificaciones en taringa V8
// ==UserScript==
// @name Taringa Notifications Title Update
// @namespace https://maag.nibiru.com.uy
// @version 1.1
// @description Agrega (1) al título de Taringa si hay notificaciones
// @author Maag
// @match https://www.taringa.net/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let intervalId;
let noloop = false;
function getNotificationsCount() {
let elementos = document.querySelectorAll('[data-id="Bubble_Bubble_span"]');
if (elementos.length >= 2) {
let segundoElemento = elementos[1];
let contenido = segundoElemento.textContent;
let numero = parseInt(contenido, 10);
return numero;
} else {
console.log("No se encontró un segundo elemento con el atributo data-id igual a 'Bubble_Bubble_span'.");
}
}
function updateTitle() {
const currentTitle = document.title;
let notificationsCount = getNotificationsCount();
if (notificationsCount > 0) {
document.title = `(${notificationsCount}) ${currentTitle.slice(4)}`;
} else {
document.title = currentTitle.slice(4);
noloop = true;
}
}
if (noloop == false){
intervalId = setInterval(updateTitle, 5000);
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
clearInterval(intervalId);
} else {
intervalId = setInterval(updateTitle, 5000);
}
})
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment