Last active
December 12, 2023 10:50
-
-
Save FrostBird347/82473292f6d84542b607b87c2ea61df5 to your computer and use it in GitHub Desktop.
A simple BetterDiscord plugin that hides the sent time of recent posts, allowing you to take screenshots without giving away your timezone.
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
/** | |
* @name HideTime | |
* @authorLink https://github.com/FrostBird347 | |
* @source https://gist.github.com/FrostBird347/82473292f6d84542b607b87c2ea61df5#gistcomment-3376137 | |
* @updateUrl https://gist.githubusercontent.com/FrostBird347/82473292f6d84542b607b87c2ea61df5/raw/HideTime.plugin.js | |
*/ | |
module.exports = class HideTime { | |
getName() {return "HideTime";} | |
getDescription() {return "Hides the timestamps of recent posts, allowing you to take screenshots without giving away your timezone.";} | |
getVersion() {return "1.0.15";} | |
getAuthor() {return "FrostBird347";} | |
load() {} | |
stop() { | |
window.clearInterval(window.HTSlowSearchID); | |
delete window.HTSlowSearchID; | |
delete window.TryHideTime; | |
} | |
start() { | |
//Simple update notifier | |
//I have been unable to figure out how to obtain the plugin's version | |
let CurrentVersion = "1.0.15"; | |
window.fetch("https://gist.githubusercontent.com/FrostBird347/82473292f6d84542b607b87c2ea61df5/raw/HideTime.plugin.js").then(function(response) { | |
response.text().then(function(text) { | |
let Lines = text.split("\t").join("").split("\n"); | |
let RemoteVersion = ""; | |
for (let l = 0; l < Lines.length; l++) { | |
if (RemoteVersion == "" && Lines[l].split(" ").join("").split("\"")[0] == "getVersion(){return") { | |
RemoteVersion = Lines[l].split(" ").join("").split("\"")[1]; | |
} | |
} | |
if (RemoteVersion != CurrentVersion) { | |
window.BdApi.UI.showToast("HideTime is outdated!\nCurrent: " + CurrentVersion + "\nLatest: " + RemoteVersion, {type: "info", icon:true, timeout: 7500}); | |
} | |
}); | |
}); | |
window.TryHideTime = function(el) { | |
try { | |
if (!el.classList.contains("HTAlreadyDone")) { | |
if (el.innerText.replace(" — \n", "").startsWith("Today at ") && !el.innerText.replace(" — \n", "").startsWith("Today at --:--")) { | |
el.innerText = "Today at --:--"; | |
} else if (el.innerText.replace(" — \n", "").startsWith("Yesterday at ") && !el.innerText.replace(" — \n", "").startsWith("Yesterday at --:--")) { | |
el.innerText = "Yesterday at --:--"; | |
} else if (el.innerText.replace(" — \n", "").replace(", ", " ").split(" ").length >= 2) { | |
el.innerText = el.innerText.replace(" — \n", "").replace(", ", " ").split(" ")[0]; | |
} | |
el.classList.add("HTAlreadyDone") | |
} | |
} catch {} | |
} | |
window.HTSlowSearchID = window.setInterval(function(){ | |
let TimeList = document.body.getElementsByTagName("TIME"); | |
for (let i = 0; i < TimeList.length; i++) { | |
window.TryHideTime(TimeList[i]); | |
} | |
}, 5000); | |
} | |
observer(changes) { | |
//window.console.log(changes); | |
for (let i = 0; i < changes.addedNodes.length; i++) { | |
try { | |
//window.console.log(changes.addedNodes[i]); | |
if (!["LI", "SPAN", "MAIN"].includes(changes.addedNodes[i].tagName) && !changes.addedNodes[i].classList.contains("backgroundFlash_e5b9ad")) { | |
throw "Skipped, element likely isn't a new timestamp" | |
} | |
//window.console.log("^ PASSED"); | |
Array.prototype.forEach.call(changes.addedNodes[i].getElementsByTagName("TIME"), function(el) { | |
window.TryHideTime(el); | |
}) | |
} catch {} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source ↑
Update Log
1.0.15
1.0.14
1.0.13
1.0.12
1.0.11
1.0.10
1.0.9
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0