forked from tastytea/userscripts
make Misskey CW toggle work with Misskey 13
This commit is contained in:
parent
ab22e1043b
commit
4dfe33bd4c
|
@ -1,9 +1,9 @@
|
|||
// ==UserScript==
|
||||
// @name Misskey CW toggle
|
||||
// @description Adds a button to toggle the visibility of all notes with content warnings on note-pages.
|
||||
// @version 2022.07.13.1
|
||||
// @version 2023.1.26.1
|
||||
// @author tastytea
|
||||
// @copyright 2022, tastytea (https://tastytea.de/)
|
||||
// @copyright 2022-2023, tastytea (https://tastytea.de/)
|
||||
// @license GPL-3.0-only
|
||||
// @namespace tastytea.de
|
||||
// @homepageURL https://schlomp.space/tastytea/userscripts
|
||||
|
@ -18,9 +18,17 @@
|
|||
let interval;
|
||||
let counter = 0;
|
||||
|
||||
function get_root() {
|
||||
const root = document.getElementsByClassName("lxwezrsl note")[0]; // MK 13
|
||||
if (root === undefined) {
|
||||
root = document.getElementsByClassName("_block note")[0]; // MK 12
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
// Toggle the visibility of each status with CW.
|
||||
function toggle() {
|
||||
const root = document.getElementsByClassName("_block note")[0];
|
||||
const root = get_root()
|
||||
if (root === undefined) {
|
||||
return;
|
||||
}
|
||||
|
@ -35,7 +43,7 @@ function toggle() {
|
|||
|
||||
// Add a “Toggle all CWs”-button.
|
||||
function add_button() {
|
||||
let root = document.getElementsByClassName("_block note")[0];
|
||||
const root = get_root()
|
||||
if (root === undefined) {
|
||||
console.error("No suitable parent-element found.");
|
||||
return;
|
||||
|
@ -54,7 +62,7 @@ function add_button() {
|
|||
}
|
||||
|
||||
function check() {
|
||||
const root = document.getElementsByClassName("_block note")[0];
|
||||
const root = get_root()
|
||||
if (root === undefined) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user