programming and technology thread (130)

97 Name: Anonymous : 2022-02-24 19:40 ID:1qbFI4cK

Made violentmonkey script that adds previews for /img/ links right into the page. Turning textboard into imageboard. I need to figure out how to turn imageboards into textboards next, I know that I can just disable images completely, but that also disables captcha.

// ==UserScript==
// @name 4-ch.net image previews
// @namespace Violentmonkey Scripts
// @match https://4-ch.net/*
// @grant none
// @version 1.0
// @author -
// @description Adds image previews for /img/ links.
// ==/UserScript==
function load_html(evt) {
var iterthis = document.getElementsByTagName("a")
if (!iterthis) return

for (var i = 0; i < iterthis.length; i++) {
var a = iterthis[i]
if (a.href.startsWith("https://4-ch.net/img/src/")) {
var filename = a.href.substring("https://4-ch.net/img/src/".length)
var index = filename.lastIndexOf(".")
filename = filename.substring(0, index)
//alert(filename)
var img = document.createElement("img")
img.src = "https://4-ch.net/img/thumb/" + filename + "s.jpg"
var br = document.createElement("br")
var nexta = document.createElement("a")
nexta.href = a.href
nexta.rel = "noreferrer noopener nofollow"
nexta.target = "_blank"
add_after(a, br)
add_after(a, nexta)
nexta.appendChild(img)
add_after(a, br)

i+=1 //skipping over "a" we just created
}
}
}
function add_after(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling)
}
window.addEventListener('DOMContentLoaded', load_html, false)

98 Name: Anonymous : 2022-02-24 19:43 ID:Heaven

Made greasemonkey script to make browsing 5ch slightly less annoying. I suspect that the old style redirect exists mostly to show ads.

// ==UserScript==
// @name 5ch.net less annoying links
// @namespace Violentmonkey Scripts
// @match https://*.5ch.net/*
// @grant none
// @version 1.0
// @author -
// @description Make links slightly less annoying to open
// @run-at document-start
// ==/UserScript==
//https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/noreferrer
//https://www.reliablesoft.net/noreferrer-noopener/
//<a href="somelink" rel="noreferrer noopener" target="_blank">
function load_html(evt) {
var iterthis = document.getElementsByTagName("a")
if (!iterthis) return

for (var i = 0; i < iterthis.length; i++) {
var a = iterthis[i]
//alert(a.href)
if (a.href.startsWith("http://jump.5ch.net/?")) {
a.href = a.href.substring("http://jump.5ch.net/?".length)
} else if (a.href.startsWith("https://jump.5ch.net/?")) {
a.href = "http://" + a.href.substring("https://jump.5ch.net/?".length)
}
}
}
window.addEventListener('DOMContentLoaded', load_html, false)

100 Name: Anonymous : 2022-02-25 07:52 ID:Heaven

Guys, http or https? Imgur supports both. Https is encrypted, so it's harder for middleman to read what you are reading. But because it is encrypted, online caching doesn't work anymore. For mails and other such matters encryption is a must, but for funny images it probably isn't that necessary?

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: