From f819aa3afea420925fe4c91a71a2756d5ed04b80 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Tue, 14 Sep 2021 13:34:19 +0530 Subject: qutebrowser config save --- config/qutebrowser/greasemonkey/#gh-pr.js# | 27 ---------- config/qutebrowser/greasemonkey/gh-pr.js | 10 ++-- config/qutebrowser/greasemonkey/google-meet.js | 71 ++++++++++++++++++++++++++ config/qutebrowser/greasemonkey/slack.js | 5 +- 4 files changed, 79 insertions(+), 34 deletions(-) delete mode 100644 config/qutebrowser/greasemonkey/#gh-pr.js# create mode 100644 config/qutebrowser/greasemonkey/google-meet.js (limited to 'config/qutebrowser/greasemonkey') diff --git a/config/qutebrowser/greasemonkey/#gh-pr.js# b/config/qutebrowser/greasemonkey/#gh-pr.js# deleted file mode 100644 index 26d444a..0000000 --- a/config/qutebrowser/greasemonkey/#gh-pr.js# +++ /dev/null @@ -1,27 +0,0 @@ -// ==UserScript== -// @name Github PR helper -// @namespace phenax.github.io -// @version 0.0.0 -// @description Github PR helper -// @author Akshay Nair -// @match *://github.com/*/pull/*/files -// ==/UserScript== - -const keys = { - n: () => document.querySelector('.js-reviewed-toggle:not(.js-reviewed-file)').click(), - N: () => Array.from(document.querySelectorAll('.js-reviewed-file')).slice(-1)[0].click(), - //j: () => { - //const $el = document.querySelector('.js-reviewed-toggle:not(.js-reviewed-file)'); - //if ($el) { - - //} - //}, -}; -w -document.addEventListener('keydown', (e) => { - console.log(e.key, e.ctrlKey); - if (keys[e.key] && e.ctrlKey) { - keys[e.key](); - } -}); - diff --git a/config/qutebrowser/greasemonkey/gh-pr.js b/config/qutebrowser/greasemonkey/gh-pr.js index 5803022..d78b787 100644 --- a/config/qutebrowser/greasemonkey/gh-pr.js +++ b/config/qutebrowser/greasemonkey/gh-pr.js @@ -4,17 +4,17 @@ // @version 0.0.0 // @description Github PR helper // @author Akshay Nair -// @match *://github.com/*/pull/*/files +// @match *://github.com/*/pull/* // ==/UserScript== const keys = { n: () => document.querySelector('.js-reviewed-toggle:not(.js-reviewed-file)').click(), N: () => Array.from(document.querySelectorAll('.js-reviewed-file')).slice(-1)[0].click(), //j: () => { - //const $el = document.querySelector('.js-reviewed-toggle:not(.js-reviewed-file)'); - //if ($el) { - - //} + //const $el = document.querySelector('.js-reviewed-toggle:not(.js-reviewed-file)'); + //if ($el) { + + //} //}, }; diff --git a/config/qutebrowser/greasemonkey/google-meet.js b/config/qutebrowser/greasemonkey/google-meet.js new file mode 100644 index 0000000..37a163b --- /dev/null +++ b/config/qutebrowser/greasemonkey/google-meet.js @@ -0,0 +1,71 @@ +// ==UserScript== +// @name Google meet mute indicator +// @namespace phenax.github.io +// @version 0.0.0 +// @description Google meet mute indicator +// @author Akshay Nair +// @match *://meet.google.com/* +// ==/UserScript== + +(() => { + const log = console.log.bind(console, '[MeetingBtns]'); + const $$ = document.querySelectorAll.bind(document); + + const $indicator = document.createElement('div'); + Object.assign($indicator.style, { + backgroundColor: 'red', + width: '200px', + height: '100px', + position: 'fixed', + zIndex: 90000, + left: 0, + top: 0, + opacity: 0, + }); + + const getMuteBtns = () => Array.from($$('[data-is-muted][role="button"]')); + + const updateMuteState = () => { + try { + const $btns = getMuteBtns(); + const $mutedBtns = $btns.filter($btn => $btn.dataset.isMuted === 'true'); + Object.assign($indicator.style, { + opacity: $mutedBtns.length === $btns.length ? 0 : 1, + }); + } catch (e) { log('update error', e); } + }; + + const observer = new MutationObserver(diffs => { + log('mutation observer'); + const muteChange = diffs.find(d => d.attributeName === 'data-is-muted'); + if (!!muteChange) { + log('updating mute state'); + updateMuteState(); + } + }); + + const init = () => { + const $muteBtns = getMuteBtns(); + log('initializing', $muteBtns); + document.body.appendChild($indicator); + + $muteBtns.forEach($btn => { + observer.observe($btn, { attributes: true, attributeFilter: ['data-is-muted'] }); + updateMuteState(); + }); + + if (window.$$$muteObserver) window.$$$muteObserver.disconnect(); + window.$$$muteObserver = observer; + }; + + const timer = setInterval(() => { + const $btns = getMuteBtns(); + const hasJoinedMeeting = $$('[data-meeting-code]').length === 0; + log('checking if joined...', hasJoinedMeeting); + if ($btns.length > 0 && hasJoinedMeeting) { + setTimeout(() => init(), 1000); + clearInterval(timer); + } + }, 500); +})(); + diff --git a/config/qutebrowser/greasemonkey/slack.js b/config/qutebrowser/greasemonkey/slack.js index b1d6cc4..2f1eeef 100644 --- a/config/qutebrowser/greasemonkey/slack.js +++ b/config/qutebrowser/greasemonkey/slack.js @@ -21,13 +21,14 @@ let count = 0; const timer = setInterval(() => { const $btns = notificationsButtons(); - console.log('>> Notification buttons', $btns); + console.log('>> [GM-N] Notification buttons', $btns); Array.from($btns) - .filter($btn => $btn.textContent.match(/enable.*notification/)) + .filter($btn => $btn.textContent.match(/enable.*notification/gi)) .forEach($btn => { $btn && $btn.click(); clearInterval(timer); + console.log('>> [GM-N] Enabled notifications') }); if (count > 10) clearInterval(timer); -- cgit v1.3.1