Last active
August 19, 2021 06:23
-
-
Save marktaiwan/91d8e88ea76f17855509ec9532dc5fd8 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Philomena booru absolute dates | |
// @namespace http://anon.invalid/philomena_abs_dates | |
// @version 2.3 | |
// @description Changes dates to be absolute on Philomena-based boorus | |
// @author Anon | |
// @match *://*.derpibooru.org/* | |
// @match *://*.trixiebooru.org/* | |
// @match *://*.ronxgr5zb4dkwdpt.onion/* | |
// @match *://*.ponybooru.org/* | |
// @match *://*.ponerpics.org/* | |
// @match *://*.twibooru.org/* | |
// @require https://raw.githubusercontent.com/soufianesakhi/node-creation-observer-js/master/release/node-creation-observer-latest.js | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
function toggleTimestamp(e) { | |
if (e.target.closest('a')) return; | |
for (const ele of document.querySelectorAll('.js-timestamp-toggle')) { | |
ele.classList.toggle('hidden'); | |
} | |
} | |
function processTimeEle(timeEle) { | |
const absTimeEle = document.createElement('span'); | |
absTimeEle.innerText = timeEle.title; | |
absTimeEle.classList.add('hidden'); | |
timeEle.before(absTimeEle); | |
[timeEle, absTimeEle].forEach(ele => { | |
ele.classList.add('js-timestamp-toggle'); | |
ele.style.cursor = 'pointer'; | |
ele.addEventListener('click', toggleTimestamp); | |
}); | |
} | |
NodeCreationObserver.init('abs-date-observer'); | |
NodeCreationObserver.onCreation('time[title]', processTimeEle); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment