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