User:Gary/comments in local time.js: Difference between revisions

Content deleted Content added
sync from User:SD0001/comments in local time.js - requested on talk
Tag: Reverted
Undid revision 1016315793 by Xaosflux (talk)
Line 1:
// Forked from [[User:Gary/comments in local time.js]]
/**
* COMMENTS IN LOCAL TIME
Line 10 ⟶ 9:
* [[Wikipedia:Comments in Local Time]]
*/
$(() => {
mw.hook('wikipage.content').add(($content) => {
/**
* Given a number, add a leading zero if necessary, so that the final number
Line 504 ⟶ 503:
 
if (isDisabledUrl) {
return;
}
// If this content already contains localcomments class, it was
// already worked on.
if ($content[0].querySelector('.localcomments')) {
return;
}
 
this.replaceText(
if ($content[0] document.querySelector('.localcommentsmw-parser-output')) {,
$content[0],
/(\d{1,2}):(\d{2}), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/
);
Line 625 ⟶ 618:
}
 
// Check if we've already ran this script.
new CommentsInLocalTime().run();
if (window.commentsInLocalTimeWasRun) {
return;
}
 
window.commentsInLocalTimeWasRun = true;
 
const commentsInLocalTime = new CommentsInLocalTime().run();
 
commentsInLocalTime.run();
});