Skip to content

Instantly share code, notes, and snippets.

@marktaiwan
Last active August 19, 2021 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marktaiwan/91d8e88ea76f17855509ec9532dc5fd8 to your computer and use it in GitHub Desktop.
Save marktaiwan/91d8e88ea76f17855509ec9532dc5fd8 to your computer and use it in GitHub Desktop.
// ==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