Last active
January 31, 2023 05:06
-
-
Save NI57721/4b3318b21df2f9bc33b1cd0d36fb7c53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Clickable list items | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description make rooms clickable. | |
// @author NI57721 | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Your code here... | |
const addButtonAttribute = () => { | |
const btnClass = "vimium_button"; | |
const itemList = document.querySelectorAll("[class*=item]"); | |
let isChildrenClickable = false; | |
Array.from(itemList).forEach(element => { | |
const children = element.children; | |
Array.from(children).forEach(child => { | |
const grandchildren = child.children; | |
Array.from(grandchildren).forEach(grandchild => { | |
grandchild.classList.add(btnClass) | |
isChildrenClickable = true; | |
}); | |
if(!isChildrenClickable) | |
child.classList.add(btnClass); | |
isChildrenClickable = true; | |
}); | |
if(!isChildrenClickable) | |
element.classList.add(btnClass); | |
isChildrenClickable = true; | |
}); | |
}; | |
document.addEventListener('keydown', addButtonAttribute, true); | |
document.addEventListener('click', addButtonAttribute); | |
window.onload = () => {setTimeout(addButtonAttribute, 5000);}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment