NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name F95 New Tag // @namespace http://tampermonkey.net/ // @version 1.2 // @description Add a "new" tag on every new tile in the latest updates of F95-zone // @author You // @match https://f95zone.to/latest/ // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; console.clear(); const storageKey = "f95-new-tag"; const previouses = JSON.parse(localStorage.getItem(storageKey)) ?? []; hookToXHR(); function process() { const nodes = document.querySelectorAll(".resource-tile"); for (let node of nodes) { const id = node.getAttribute("data-thread-id"); const timeNode = node.querySelector(".resource-tile_info-meta_time span"); let minutes = 0; if (timeNode.classList.value.includes('min')) { minutes = +timeNode.textContent; } else if (timeNode.classList.value.includes('hr')) { minutes = +timeNode.textContent * 60; } else if (timeNode.classList.value.includes('day')) { minutes = +timeNode.textContent * 24 * 60; } else if (timeNode.classList.value.includes('week')) { minutes = +timeNode.textContent * 7 * 24 * 60; } const date = new Date(); date.setMinutes(date.getMinutes() - minutes); const time = dateToNumber(JSON.stringify(date)); let previous = previouses.find((element) => element.id == id); if (previous) { if (+previous.time === time) { continue; } previous.time = time; } else { previous = { id, time }; previouses.push(previous); } const newNode = document.createElement("div"); newNode.classList.add("new-tag"); newNode.textContent = "NEW"; newNode.style.top = "0px"; newNode.style.left = "0px"; newNode.style.backgroundColor = "#ba4545"; newNode.style.display = "inline-block"; newNode.style.padding = "2px 4px"; newNode.style.borderBottomRightRadius = "4px"; newNode.style.position = "absolute"; newNode.style.boxShadow = "1px 1px 1px 0px rgba(0,0,0,0.75)"; newNode.style.fontSize = "12px"; node.append(newNode); } localStorage.setItem(storageKey, JSON.stringify(previouses)); } function dateToNumber(date) { return +date.split("T")[0].replace(/-/g, "").slice(1); } function hookToXHR() { var origOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function () { this.addEventListener("load", function (evt) { if (evt.target.responseURL.includes("new_latest")) { setTimeout(() => { process(); }, 0); } }); origOpen.apply(this, arguments); } } })();