+ // TODO hide/unhide buttons
+ node.querySelectorAll(".topics .row").forEach(function (el) {
+ const thread_link = el.querySelector("a.topictitle[href^='./view']");
+ const thread_id = parseInt(thread_link.getAttribute("href").match(/t=([0-9]+)/)[1]);
+
+ const btn = document.createElement('a');
+ btn.className = "dfde-hide-stuff-btn"
+ btn.style.float = "right";
+ btn.style.opacity = opacity_default;
+ let icon = hidden_threads.indexOf(thread_id) >= 0 ? "fa-eye" : "fa-eye-slash";
+ btn.innerHTML = `<i class="icon ${icon} fa-fw icon-lightgrey icon-xl"></i>`;
+
+ btn.addEventListener("mouseenter", function () {
+ btn.style.opacity = opacity_highlight;
+ });
+ btn.addEventListener("mouseleave", function () {
+ btn.style.opacity = opacity_default;
+ });
+ btn.addEventListener("click", function () {
+ hidden_threads.indexOf(thread_id) >= 0 ? unhide_thread(thread_id) : hide_thread(thread_id);
+ update_info_buttons();
+ // just re-add icons
+ add_thread_icons();
+ });
+ el.querySelectorAll(".lastpost span .dfde-hide-stuff-btn").forEach(btn => btn.remove())
+ el.querySelector(".lastpost span").append(btn);
+ });
+ }
+
+ function update_info_buttons() {
+ try {
+ const hidden_threads = get_hidden_threads();
+ const hidden_users = get_hidden_users();
+ node.querySelector('#hidden_threads_btn').innerHTML = `T (${hidden_threads.length})`;
+ node.querySelector('#hidden_users_btn').innerHTML = `U (${hidden_users.length})`;
+ } catch (e) {
+ // just on the wrong page, I guess
+ }
+ }
+
+ add_control_buttons(node);
+ add_thread_icons(node);
+ add_user_icons(node);
+ hide_threads(node);
+ hide_users(node);
+ }
+
+ function init(mutations, observer) {
+ for (const mutation of mutations) {
+ for (const node of mutation.addedNodes) {
+ node_wrap(node)
+ }