Add spoiler bbcode
#13092
probably both to chat and forum but also rewrite chat bbcode parsers for both new and old because i hate hate hate HATE it
https://sig.flash.moe/signature.png
#13093
ok yes please thank you!

OPEEEN WIDEEEEE BRRRAAAAPPPP PFFFRRRTFTFTF PPPPOOPPBBB SWEWWE PRRRRBBBT Ble- ahh AAHHHHHHH PETER PLE- PLOP POLOP BRRAAAAAPPPPP BBBREEEW PRRRREAAAAAPPPPP I-I’m gonna be sick again... peter please let me g- BRREAPPPPPOPO POPPPFTTFTR

#13094
wait i though there was a spoiler tag hold on let me confirm this [spoiler]gilda dies at the end of rigoletto [/spoiler] sheesh i sure hope that works if not you are sll FYVKDD
//i.fii.moe/EEtDbYEICrUbLOFjkwKVQ7OUJWJR-ejl
https://i.fii.moe/uYgszrmMmZJ5PQz6UXu3x7TZL6m1hmZV
#13095
2015 forum had one and it had a tendency to break everything because cop out regex "parsing"
https://sig.flash.moe/signature.png
#16129
pls consider revisiting this when you can thx mom
//i.fii.moe/EEtDbYEICrUbLOFjkwKVQ7OUJWJR-ejl
https://i.fii.moe/uYgszrmMmZJ5PQz6UXu3x7TZL6m1hmZV
#16130
i plan on figuring out how to make the bbcode parser not stupid and how to roll my own markdown parser during my upcoming break. i have yet to find That Click when it comes to the concept of parsing, hopefully the book i picked up during the summer break will help me figure things out, i haven't had the chance to go through it yet.
https://sig.flash.moe/signature.png
#16131
this should work :D


// ==UserScript==
// @name Fla_shh
// @namespace https://saikuru.net
// @version 1.12
// @description Handle [spoiler]bbcode[/spoiler]
// @author saikuru0
// @match *://flashii.net/*
// @grant none
// ==/UserScript==

(function() {
	'use strict';

	function replace_spoilers() {
		var spoiler_elements = document.querySelectorAll('div.forum__post__text');

		spoiler_elements.forEach(function(spoiler_element) {
			var spoiler_text = spoiler_element.textContent;

			var replaced_text = spoiler_text.replace(/\[spoiler\](.*?)\[\/spoiler\]/g, function(match, p1) {
				return '<span class="spoiler-content" style="cursor: pointer; color: var(--accent-colour);" onclick="toggle_spoiler(this)">[[[SPOILER]]]</span><span class="spoiler-hidden" style="display: none; color: var(--accent-colour);" onclick="toggle_spoiler(this.previousElementSibling)">' + p1 + '</span>';
			});

			spoiler_element.innerHTML = replaced_text;
		});
	}

	window.toggle_spoiler = function(element) {
		var spoiler_hidden = element.nextElementSibling;
		spoiler_hidden.style.display = (spoiler_hidden.style.display === 'none' || spoiler_hidden.style.display === '') ? 'inline' : 'none';
		element.innerText = element.innerText === '[[[SPOILER]]]' ? '' : '[[[SPOILER]]]'; 
	};

	document.addEventListener('DOMContentLoaded', replace_spoilers);

	replace_spoilers();
})();
https://saikuru.net/sig
#16132
there's a reason i'm not integrating it into the current bbcode system yet, same goes for a quote bbcode and that is that doing it through regex leads to fuckery. the old forum system regularly had explosions with these and the current bbcode system is almost a direct port of that one so the same would ensue, the same reason why emoticons are currently absent from the forum actually
https://sig.flash.moe/signature.png
#16133
yeah i just put this out there as a duct tape soluction
https://saikuru.net/sig