aboutsummaryrefslogtreecommitdiff
path: root/config/qutebrowser/greasemonkey
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-12-21 18:52:51 +0530
committerAkshay Nair <phenax5@gmail.com>2020-12-21 18:52:51 +0530
commitf1cf59ce2df9204f818cfd038538a2a31a5c2262 (patch)
tree35b0a21501615b7551514262b96e9d8113375cbc /config/qutebrowser/greasemonkey
parent6ff5a17adcf1ed72cd2f1c7bff606bdd3352b3bb (diff)
downloadnixos-config-f1cf59ce2df9204f818cfd038538a2a31a5c2262.tar.gz
nixos-config-f1cf59ce2df9204f818cfd038538a2a31a5c2262.zip
Adds qutebrowser config
Diffstat (limited to 'config/qutebrowser/greasemonkey')
-rw-r--r--config/qutebrowser/greasemonkey/duckduckgo.js16
-rw-r--r--config/qutebrowser/greasemonkey/gh-pr.js27
-rw-r--r--config/qutebrowser/greasemonkey/hris-reg.js27
-rw-r--r--config/qutebrowser/greasemonkey/slack.js36
-rw-r--r--config/qutebrowser/greasemonkey/whatsapp.js57
-rw-r--r--config/qutebrowser/greasemonkey/youtube-ad.js51
-rw-r--r--config/qutebrowser/greasemonkey/youtube-no-autoplay.js111
7 files changed, 325 insertions, 0 deletions
diff --git a/config/qutebrowser/greasemonkey/duckduckgo.js b/config/qutebrowser/greasemonkey/duckduckgo.js
new file mode 100644
index 0000000..f1c9247
--- /dev/null
+++ b/config/qutebrowser/greasemonkey/duckduckgo.js
@@ -0,0 +1,16 @@
+// ==UserScript==
+// @name Github PR helper
+// @namespace phenax.github.io
+// @version 0.0.0
+// @description Github PR helper
+// @author Akshay Nair
+// @match *://duckduckgo.com/*
+// ==/UserScript==
+
+(() => {
+ const load = str =>
+ str.split(' ').forEach(x => (document.cookie = x));
+
+ load('ae=d; 5=2; s=m; p=-2; am=osm; a=JetBrains%20Mono; t=JetBrains%20Mono; j=0f0c19; 7=15121f; 21=1f1c29;')
+})();
+
diff --git a/config/qutebrowser/greasemonkey/gh-pr.js b/config/qutebrowser/greasemonkey/gh-pr.js
new file mode 100644
index 0000000..5803022
--- /dev/null
+++ b/config/qutebrowser/greasemonkey/gh-pr.js
@@ -0,0 +1,27 @@
+// ==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) {
+
+ //}
+ //},
+};
+
+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/hris-reg.js b/config/qutebrowser/greasemonkey/hris-reg.js
new file mode 100644
index 0000000..852d357
--- /dev/null
+++ b/config/qutebrowser/greasemonkey/hris-reg.js
@@ -0,0 +1,27 @@
+// ==UserScript==
+// @name Github PR helper
+// @namespace phenax.github.io
+// @version 0.0.0
+// @description Github PR helper
+// @author Akshay Nair
+// @match *://hris.peoplelabs.com/attendance/regularization/apply-regularization/*
+// ==/UserScript==
+
+const $ = document.querySelector.bind(document);
+
+const keys = {
+ r: () => {
+ $('#firstintime').value = '10:30';
+ $('#lastouttime').value = '18:30';
+ $('#reason').value = 'Work from home';
+ setTimeout(() => $('input[type="submit"]').click(), 500);
+ },
+};
+
+document.addEventListener('keydown', (e) => {
+ if (keys[e.key] && e.ctrlKey) {
+ keys[e.key]();
+ }
+});
+
+
diff --git a/config/qutebrowser/greasemonkey/slack.js b/config/qutebrowser/greasemonkey/slack.js
new file mode 100644
index 0000000..b1d6cc4
--- /dev/null
+++ b/config/qutebrowser/greasemonkey/slack.js
@@ -0,0 +1,36 @@
+// ==UserScript==
+// @name Slack helper
+// @namespace phenax.github.io
+// @version 0.0.0
+// @description Slack helper
+// @author Akshay Nair
+// @match *://app.slack.com/*
+// ==/UserScript==
+
+const keys = {};
+
+document.addEventListener('keydown', (e) => {
+ if (keys[e.key] && e.ctrlKey) {
+ keys[e.key]();
+ }
+});
+
+const notificationsButtons = () => document.querySelectorAll('[data-qa="banner"][class*=notifications] button');
+
+let count = 0;
+const timer = setInterval(() => {
+ const $btns = notificationsButtons();
+
+ console.log('>> Notification buttons', $btns);
+
+ Array.from($btns)
+ .filter($btn => $btn.textContent.match(/enable.*notification/))
+ .forEach($btn => {
+ $btn && $btn.click();
+ clearInterval(timer);
+ });
+
+ if (count > 10) clearInterval(timer);
+ count += 1;
+}, 1000);
+
diff --git a/config/qutebrowser/greasemonkey/whatsapp.js b/config/qutebrowser/greasemonkey/whatsapp.js
new file mode 100644
index 0000000..3bd1ab5
--- /dev/null
+++ b/config/qutebrowser/greasemonkey/whatsapp.js
@@ -0,0 +1,57 @@
+// ==UserScript==
+// @name Whatsapp helper
+// @namespace phenax.github.io
+// @version 0.0.0
+// @description Whatsapp helper
+// @author Akshay Nair
+// @match *://web.whatsapp.com/*
+// ==/UserScript==
+
+
+const getPosition = $el => parseInt($el.style.transform.match(/translateY\((.*)\)/)[1], 10);
+
+const getContacts = () => Array.from(document
+ .querySelectorAll('#pane-side > div:nth-child(1) > div > div > div'))
+ .sort(($a, $b) => getPosition($a) - getPosition($b))
+
+const getNext = () => {
+ const list = getContacts();
+ const current_selected = list.findIndex($el => !!$el.querySelector('[aria-selected=true]'));
+ return list[current_selected + 1];
+};
+const getPrev = () => {
+ const list = getContacts();
+ const current_selected = list.findIndex($el => !!$el.querySelector('[aria-selected=true]'));
+ return current_selected <= 0 ? null : list[current_selected - 1];
+};
+
+const clickableElem = $el => $el && $el.querySelector('[aria-selected] > div');
+
+const click = $el => $el && $el.dispatchEvent(new MouseEvent('mousedown', {
+ screenX: 5,
+ screenY: 5,
+ bubbles: true,
+ cancellable: true,
+ relatedTarget: $el,
+}));
+
+const keys = {
+ j: () => click(clickableElem(getNext())),
+ k: () => click(clickableElem(getPrev())),
+};
+
+document.addEventListener('keydown', (e) => {
+ if (keys[e.key] && e.ctrlKey) {
+ keys[e.key]();
+ }
+});
+
+const timer = setInterval(() => {
+ if (Notification.permission !== 'default') {
+ clearInterval(timer);
+ return;
+ }
+
+ Notification.requestPermission().then(console.log);
+}, 1000);
+
diff --git a/config/qutebrowser/greasemonkey/youtube-ad.js b/config/qutebrowser/greasemonkey/youtube-ad.js
new file mode 100644
index 0000000..f545309
--- /dev/null
+++ b/config/qutebrowser/greasemonkey/youtube-ad.js
@@ -0,0 +1,51 @@
+// ==UserScript==
+// @name Hide youtube google ad
+// @namespace vince.youtube
+// @version 2.4.1
+// @description hide youtube google ad,auto click "skip ad"
+// @author vince ding
+// @match *://www.youtube.com/*
+// ==/UserScript==
+
+(function() {
+ 'use strict';
+ var closeAd=function (){
+ var css = '.video-ads .ad-container .adDisplay,#player-ads,.ytp-ad-module,.ytp-ad-image-overlay{ display: none!important; }',
+ head = document.head || document.getElementsByTagName('head')[0],
+ style = document.createElement('style');
+
+ style.type = 'text/css';
+ if (style.styleSheet){
+ style.styleSheet.cssText = css;
+ } else {
+ style.appendChild(document.createTextNode(css));
+ }
+
+ head.appendChild(style);
+ };
+ var skipInt;
+ var log=function(msg){
+ console.log(msg);
+ };
+ var skipAd=function(){
+ //ytp-ad-preview-text
+ //ytp-ad-skip-button
+ var skipbtn=document.querySelector(".ytp-ad-skip-button.ytp-button")||document.querySelector(".videoAdUiSkipButton ");
+ //var skipbtn=document.querySelector(".ytp-ad-skip-button ")||document.querySelector(".videoAdUiSkipButton ");
+ if(skipbtn){
+ skipbtn=document.querySelector(".ytp-ad-skip-button.ytp-button")||document.querySelector(".videoAdUiSkipButton ");
+ log("skip");
+ skipbtn.click();
+ if(skipInt) {clearTimeout(skipInt);}
+ skipInt=setTimeout(skipAd,500);
+ }else{
+ log("checking...");
+ if(skipInt) {clearTimeout(skipInt);}
+ skipInt=setTimeout(skipAd,500);
+ }
+ };
+
+ closeAd();
+ skipAd();
+
+})();
diff --git a/config/qutebrowser/greasemonkey/youtube-no-autoplay.js b/config/qutebrowser/greasemonkey/youtube-no-autoplay.js
new file mode 100644
index 0000000..80a763a
--- /dev/null
+++ b/config/qutebrowser/greasemonkey/youtube-no-autoplay.js
@@ -0,0 +1,111 @@
+// ==UserScript==
+// @author James Edward Lewis II
+// @namespace greasyfork.org
+// @name Disable audio/video autoplay
+// @description Ensures that HTML5 audio and video elements do not autoplay, based on http://diveintohtml5.info/examples/disable_video_autoplay.user.js
+// @icon http://diveintohtml5.info/favicon.ico
+// @include *
+// @grant none
+// @version 1.2.0
+// @run-at document-end
+// @copyright 2015 James Edward Lewis II
+// @match *://www.youtube.com/*
+// ==/UserScript==
+
+var arVideos = document.getElementsByTagName('video'), arAudio = document.getElementsByTagName('audio'), vl = arVideos.length,
+ al = arAudio.length, loc = window.document.location.toString(), ytPlayer = document.getElementById('movie_player'),
+ ytVars = ytPlayer ? ytPlayer.getAttribute('flashvars') : '', arEmbeds = document.getElementsByTagName('embed'),
+ el = arEmbeds.length, ytPause = document.getElementsByClassName('ytp-button-pause'),
+ cb_load = function cb_load(fnc) { // Just for those who still use IE7Pro; IE8 and earlier do not support addEventListener: https://gist.github.com/eduardocereto/955642
+ 'use strict';
+ if (window.addEventListener) { // W3C model
+ window.addEventListener('load', fnc, false);
+ return true;
+ } else if (window.attachEvent) { // Microsoft model
+ return window.attachEvent('onload', fnc);
+ } else { // Browser doesn't support W3C or MSFT model, go on with traditional
+ if (typeof window.onload === 'function') {
+ // Object already has a function on traditional
+ // Let's wrap it with our own function inside another function
+ fnc = (function wrap(f1, f2) {
+ return function wrapped() {
+ f1.apply(this, arguments);
+ f2.apply(this, arguments);
+ };
+ }(window.onload, fnc));
+ }
+ window.onload = fnc;
+ return true;
+ }
+ }, nodeRefresh = function nodeRefresh(nod) {
+ 'use strict';
+ var orig = nod.style.display;
+ nod.style.display = (orig === 'none') ? 'block' : 'none';
+ nod.style.display = orig;
+ }, vidStop = function vidStop(vid) {
+ 'use strict';
+ vid.pause();
+ vid.oncanplay = null;
+ vid.onplay = null;
+ }, stopVideo, i;
+for (i = vl - 1; i >= 0; i--) arVideos[i].autoplay = false;
+for (i = al - 1; i >= 0; i--) arAudio[i].autoplay = false;
+
+// attempted workaround for Vine and modern YouTube, except on YouTube playlists, based on https://greasyfork.org/en/scripts/6487-pause-all-html5-videos-on-load
+if (!loc.match(/^https?\:\/\/(?:\w+\.)?youtube(?:-nocookie)?\.com(?:\:80)?\/watch\?.*list=[A-Z]/i)) {
+ stopVideo = function stopVideo() {
+ 'use strict';
+ var autoPlay, i, yl = ytPause ? +ytPause.length : 0, vidStopper = function vidStopper() {vidStop(autoPlay);};
+ if (yl) { // This comes from Stop Youtube HTML5 Autoplay by Leslie P. Polzer of PORT ZERO <polzer@port-zero.com>: http://www.port-zero.com/en/chrome-plugin-stop-html5-autoplay/
+ for (i = yl - 1; i >= 0; i--) ytPause[i].click();
+ } else {
+ for (i = vl - 1; i >= 0; i--) {
+ autoPlay = arVideos[i];
+ if (autoPlay && autoPlay.readyState === 4) {
+ vidStop(autoPlay);
+ autoPlay.currentTime = 0;
+ nodeRefresh(autoPlay);
+ } else {
+ autoPlay.oncanplay = vidStopper;
+ autoPlay.onplay = vidStopper;
+ }
+ }
+ for (i = al - 1; i >= 0; i--) {
+ autoPlay = arAudio[i];
+ if (autoPlay && autoPlay.readyState === 4) {
+ vidStop(autoPlay);
+ autoPlay.currentTime = 0;
+ nodeRefresh(autoPlay);
+ } else {
+ autoPlay.oncanplay = vidStopper;
+ autoPlay.onplay = vidStopper;
+ }
+ }
+ }
+ };
+ if (!loc.match(/^https?\:\/\/(?:\w+\.)?youtube(?:-nocookie)?\.com[\:\/]/i) || !vl) cb_load(stopVideo);
+ else cb_load(function delayedYTstop() {'use strict'; setTimeout(stopVideo, 0);});
+}
+
+// attempted workaround for old Flash-based YouTube, for older browsers, based on http://userscripts-mirror.org/scripts/review/100858
+if (loc.match(/^https?\:\/\/(?:\w+\.)?youtube(?:-nocookie)?\.com[\:\/]/i) && loc.indexOf('list=') === -1 && !vl && ytVars)
+ cb_load(function delayedYTstop() {'use strict'; setTimeout(function stopOldYT() { // in video page : profile page
+ ytPlayer.setAttribute('flashvars', (loc.indexOf('/watch') !== -1) ? 'autoplay=0&' + ytVars : ytVars.replace(/autoplay=1/i, 'autoplay=0'));
+ ytPlayer.src += (ytPlayer.src.indexOf('#') === -1) ? '#' : '&autoplay=0';
+ nodeRefresh(ytPlayer);
+ }, 0);});
+
+// attempted workaround for Billy-based video players on Tumblr, based on https://greasyfork.org/en/scripts/921-tumblr-disable-autoplay
+// which is also the source of all the CSSOM tomfoolery elsewhere in this script
+if (loc.match(/^https?\:\/\/(?:\w+\.)*tumblr\.com[\:\/]/i))
+ cb_load(function stopBillyTumblr() {
+ 'use strict';
+ var autoPlay, i;
+ for (i = el - 1; i >= 0; i--) {
+ autoPlay = arEmbeds[i];
+ if (autoPlay && autoPlay.src.match(/autoplay=true/gi)) {
+ autoPlay.src = autoPlay.src.replace(/autoplay=true/gi, 'autoplay=false');
+ nodeRefresh(autoPlay);
+ }
+ }
+ });