aboutsummaryrefslogtreecommitdiff
path: root/config/qutebrowser/greasemonkey
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2021-09-14 13:34:19 +0530
committerAkshay Nair <phenax5@gmail.com>2021-09-14 13:34:19 +0530
commitf819aa3afea420925fe4c91a71a2756d5ed04b80 (patch)
tree51485da02eda97596faf55aec4881af8134b1e72 /config/qutebrowser/greasemonkey
parent994bda7f51d6967087832218d7d3613f37960c9f (diff)
downloadnixos-config-f819aa3afea420925fe4c91a71a2756d5ed04b80.tar.gz
nixos-config-f819aa3afea420925fe4c91a71a2756d5ed04b80.zip
qutebrowser config save
Diffstat (limited to 'config/qutebrowser/greasemonkey')
-rw-r--r--config/qutebrowser/greasemonkey/#gh-pr.js#27
-rw-r--r--config/qutebrowser/greasemonkey/gh-pr.js10
-rw-r--r--config/qutebrowser/greasemonkey/google-meet.js71
-rw-r--r--config/qutebrowser/greasemonkey/slack.js5
4 files changed, 79 insertions, 34 deletions
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);