Skip to content

Instantly share code, notes, and snippets.

@joaovitorzv
Created January 26, 2022 23:27
Show Gist options
  • Save joaovitorzv/8dd955a5e4aee2fb3644ee5047b610fc to your computer and use it in GitHub Desktop.
Save joaovitorzv/8dd955a5e4aee2fb3644ee5047b610fc to your computer and use it in GitHub Desktop.
user scripts
// ==UserScript==
// @name Deus bençoi
// @namespace http://tampermonkey.net/
// @version 0.1
// @description perguntaram ao dalai lama o mais te supreende na humanidade e ele respondeu: tumba la tumba é o barulho do
// @author joao vito
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?domain=twitter.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
let lastUrl = location.href;
new MutationObserver(() => {
const url = location.href;
if (url !== lastUrl && url.includes("search")) {
lastUrl = url;
onUrlChange()
}
}).observe(document, {subtree: true, childList: true});
function onUrlChange() {
let checkExist = setInterval(function() {
if (document.getElementsByClassName('css-1dbjc4n r-1l7z4oj r-ymttw5').length) {
const menu = document.getElementsByClassName('css-1dbjc4n r-1l7z4oj r-ymttw5')
const btnContainer = document.createElement('div')
btnContainer.innerHTML = `<div class="css-1dbjc4n r-1awozwy r-18u37iz r-16y2uox r-1wtj0ep"><div dir="auto" class="css-901oao r-1fmj7o5 r-37j5jr r-a023e6 r-16dba41 r-rjixqe r-bcqeeo r-qvutc0"><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Local lang</span></div><div class="css-1dbjc4n r-1joea0r r-lrvibr"><div class="css-1dbjc4n r-sdzlij r-xf4iuw r-1ny4l3l r-edyy15 r-o7ynqc r-6416eg"><div class="css-1dbjc4n r-1awozwy r-kemksi r-1n03560 r-nsiyw1 r-1phboty r-d045u9 r-z80fyv r-1777fci r-19wmn03"></div></div><input name="Location" type="radio" aria-posinset="2" aria-setsize="2" class="r-1p0dtai r-1ei5mc7 r-1pi2tsx r-1d2f490 r-crgep1 r-orgf3d r-t60dpp r-u8s1d r-zchlnj r-ipm5af r-13qz1uu"></div></div>`
btnContainer.addEventListener("click", () => {
let URL = window.location.href
URL = URL.split('&')
const URLWithLocalLang = URL[0] + '%20lang:pt'
window.location.replace(URLWithLocalLang)
})
menu[0].appendChild(btnContainer)
clearInterval(checkExist);
}
}, 1000);
}
})();
// ==UserScript==
// @name Twitch highlight just chatting
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.twitch.tv/
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitch.tv
// @grant none
// ==/UserScript==
(function() {
'use strict';
let channels = []
let currentObserve = document
/*
setTimeout(() => {
channels = document.querySelectorAll('.gYwlvg')
const channelsList = document.getElementsByClassName('InjectLayout-sc-588ddc-0 dBaosp tw-transition-group')[0]
highlight()
}, 10000)
*/
function highlight() {
console.log('highlighted')
for (let i=0; i < channels.length; i++) {
if (channels[i].innerText === 'Just Chatting') {
channels[i].classList.remove('gYwlvg')
}
}
}
const observer = new MutationObserver(() => {
console.log('MUTATED ===============')
let channelsContainer = document.getElementsByClassName('InjectLayout-sc-588ddc-0 dBaosp tw-transition-group')[0]
// content loadaded highlight
if (channelsContainer.children.length > 0) {
channels = document.querySelectorAll('.gYwlvg')
highlight()
// then only observe channelsContainer
if (currentObserve === document) {
observer.disconnect()
observer.observe(channelsContainer, {subtree: true, childList: true})
currentObserve = channelsContainer
}
}
})
observer.observe(currentObserve, {subtree: true, childList: true})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment