Last active
April 2, 2021 06:53
-
-
Save pxeger/ed887a9dc3566c98a8a11b77735f49b5 to your computer and use it in GitHub Desktop.
SE chat: remove "X hours later" message
This file contains 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
// ==UserScript== | |
// @name Remove "X Hours Later" text | |
// @namespace https://_.pxeger.com/19thByte | |
// @version 1.1 | |
// @description Remove the useless "X Hours Later" message that appears on SE chat | |
// @author Patrick Reader <_@pxeger.com> | |
// @match https://chat.stackexchange.com/rooms/* | |
// @icon https://chat.stackexchange.com/favicon.ico | |
// @grant none | |
// @updateURL https://gist.github.com/pxeger/ed887a9dc3566c98a8a11b77735f49b5 | |
// ==/UserScript== | |
/* Go to Settings -> User Includes and add `https://chat.stackexchange.com/transcripts/*` | |
if you want this to be enabled for historical chat transcripts as well | |
*/ | |
(function() { | |
'use strict'; | |
function hide() { | |
for (const message of document.querySelectorAll(".system-message")) { | |
if (message.innerText.match(/^\d+ hours? later…$/) || message.innerText.match(/^The last message was posted \d+ hours? ago.$/)) { | |
message.parentElement.hidden = true; | |
} | |
} | |
} | |
const observer = new MutationObserver(hide); | |
observer.observe(document.getElementById("chat"), {childList: true}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment