GC - Neoboard Post Format Remover

Add buttons to neoboard posts to wipe out all formatting in a post.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         GC - Neoboard Post Format Remover
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add buttons to neoboard posts to wipe out all formatting in a post.
// @author       Twiggies
// @match        *://www.grundos.cafe/neoboards/topic/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// @license      MIT
// ==/UserScript==



(function() {
    'use strict';

    //Get all the post timestamps to shove the buttons into.
    const postTimestampList = document.querySelectorAll('.post_timestamp')

    //Add button to each timestamp.
    for (let i = 0; i < postTimestampList.length; i++) {
        //Get the ID of the post.
        // console.log(Array.from(postTimestampList[i].classList).filter(function (str) { return str.includes('post_id'); })[0]);
        const postID = Array.from(postTimestampList[i].classList).filter(function (str) { return str.includes('post_id'); })[0];
        if (postID != undefined) {
            const formatButton = document.createElement('a');
            const buttonImage = document.createElement('img');
            buttonImage.src = "https://i.imgur.com/UT6QFio.png";
            buttonImage.title = "Remove Formatting";
            formatButton.appendChild(buttonImage);
            // formatButton.appendChild(document.createTextNode('[Remove Formatting]'));
            formatButton.addEventListener("click", function() {
                //Get the post_content with the same ID.
                const postContent = document.getElementsByClassName('post_content ' + postID)[0];
                if (postContent != undefined) {
                    //Remove the formatting of the textin that post.
                    for(var i = 0, elems = postContent.getElementsByTagName('*'), len = elems.length; i < len; i++) {
                        elems[i].removeAttribute('style');
                    }
                    console.log(postContent);
                }
            })
            postTimestampList[i].lastElementChild.insertAdjacentElement('afterbegin', formatButton);
        }
    }
    // const postList = document.querySelectorAll('.post_content')
})();