@-posting

Link to posts in the same 4chan thread with "@".

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name		@-posting
// @version		0.7.0.0
// @namespace	atposting
// @license		WTFPL
// @include		*://boards.4chan.org/*
// @run-at		document-end
// @grant		none
// @description Link to posts in the same 4chan thread with "@".
// ==/UserScript==

var updateTextChildren = function(node, callback) {
	for (var i = 0; i < node.childNodes.length; i++) {
		var cn = node.childNodes[i];
		if (cn.nodeType === 3) {
			callback(cn);
		};
	};
}

var twitterify = function(targets) {
	Array.prototype.forEach.call(targets, function(target) {
		updateTextChildren(target, function(x) {
			var html = x.nodeValue.replace(
				/#([a-zA-Z]+)/g,
				'<a href="https://archive.rebeccablacktech.com/g/?task=search&search_text=%23$1">#$1</a>'
			).replace(
				/@([0-9]+)/g,
				'<a href="#p$1" class="quotelink">@$1</a>'
			).replace(
				/Dear ([0-9]+)/g,
				'Dear <a href="#p$1" class="quotelink">$1</a>'
			);
			var span = document.createElement("span");
			span.innerHTML = html;
			x.parentNode.replaceChild(span, x);
		});
	});
};

var observer = new MutationObserver(function(mutations) {
	mutations.forEach(function(mutation) {
		twitterify(mutation.addedNodes);
	});
});

observer.observe(document.querySelector('.board .thread'), { attributes: true, childList: true });
twitterify(document.querySelectorAll('.postMessage'));