This thread is for sharing custom userscripts for nanochan. These can enable functionality that is usually expected of a non-javascript site.
Always check the source code of your userscripts. Do NOT run untrusted userscripts. If you are worried about your security or anonymity, do not run any userscripts at all.
Here's a userscript that replaces the displayed datetext with the datetime value instead because I prefer the format of it. It could probably be formatted better but this is good enough. Should be fairly simple to understand!
// UserScript // @name nanochanDateChange
// @namespace nanochanUserScript
// @version 0.1
// @description Formats all <time> elements to have the Date the same as its datetime attribute. IE Formats to Year-Month-Day Hour:Minute:SS
// @author Anonymous
// @match http://nanochanxv2lxnqi.onion/nano/* // @grant none
// /UserScript
(function() {
'use strict';
var timeTags = document.getElementsByTagName("time");
for(var i = 0; i < timeTags.length; i++)
{
timeTags.item(i).innerHTML = timeTags.item(i).getAttribute("datetime");
}
})();
A dumb little script I made to learn javascript, and to have an excuse to bump this thread for interest
The GM_addStyle line needs to be removed if using anything but tampermonkey, since I can't find any other fucking way to use css in a userscript on firecucks (crazy cors restrictions) and a heavily csp-restricted site like this one.
Remove the ~'s in between the two equals "=~="
var x = document.getElementsByClassName('post-email');
GM_addStyle('div.post>div.post-header>span.post-sageindicator{color:#c00}');
// GM_addStyle('div.post>div.post-header>span.post-sageindicator{color:#c00;font-weight:bold}');
for (var i = 0; i < x.length; i++) {
if (x[i].href.match('mailto:sage') != null) {
var el = document.createElement('span');
el.classList.add('post-sageindicator');
el.textContent = 'sage!';
var ws = document.createTextNode('\u00A0');
var y = x[i].parentElement.parentElement;
var z = x[i].closest('div.post-header').getElementsByClassName('post-date')[0];
>>1308 >mfw I became the pajeet
Damn, that seems pretty obvious in hindsight. In my defense I had almost no idea how webdev works before writing that script
>>1329 This will be done soon (in sakamoto) due to technical reasons, anyway. No choice since sakamoto is a static generator (this will allow for significantly reduced page load times).
// Change this to true to keep mod tools
const is_moderator = false;
const rtf = new Intl.RelativeTimeFormat('en', {numeric: 'auto'});
function relativeTime(post) {
let date = post.querySelector('.post-date');
let time = new Date(date.querySelector('time').dateTime);
let difference = new Date() - time;
difference /= 1000;
let unit = 'second';
if(difference > 60) {
unit = 'minute';
difference /= 60;
}
if(difference > 60) {
unit = 'hour';
difference /= 60;
}
if(difference > 24) {
unit = 'day';
difference /= 24;
}
if(difference > 7) {
unit = 'week';
difference /= 7;
}
>>1456 Who the fuck needs relative time? For what purpose? It's the most useless retarded web 3.0 concept out there. It makes flat design look inspired.
>>2732 Who the fuck needs absolute time? Why do I care that you made your post at 4:50 utc? What I care is if you made your post recently, and are likely to see my reply, or if it was weeks ago and you'll never respond.
>>2740 Absolute time gives you the ability to calculate exact time of posts, response times and timezones. It gives correct dates for screenshots, it can be easily converted to other time formats like unix time, and generally it's entirely better than your plebian format. Disgusting peasant.
This thread is for sharing custom userscripts for nanochan. These can enable functionality that is usually expected of a non-javascript site.
Always check the source code of your userscripts. Do NOT run untrusted userscripts. If you are worried about your security or anonymity, do not run any userscripts at all.