moving away from qutebrowser to firefox with tridactyl
This commit is contained in:
parent
b2074d2024
commit
0bb1ef081e
13 changed files with 19 additions and 1017 deletions
5
bin/webcam-fix
Executable file
5
bin/webcam-fix
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
sudo modprobe v4l2loopback devices=1 exclusive_caps=1 video_nr=4 card_label="virt_webcam"
|
||||
ffmpeg -f v4l2 -input_format mjpeg -framerate 30 -video_size 1280x720 -i /dev/video-webcam -vcodec copy -pix_fmt yuyv422 -f v4l2 /dev/video4
|
||||
sudo rmmod v4l2loopback
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
# this is a simple config for herbstluftwm
|
||||
|
||||
PATH="$PATH:$HOME/.local/bin"
|
||||
|
||||
hc() {
|
||||
herbstclient "$@"
|
||||
}
|
||||
|
@ -31,8 +33,8 @@ hc keybind $Mod-Shift-q quit
|
|||
hc keybind $Mod-Control-r reload
|
||||
hc keybind $Mod-Shift-c close
|
||||
hc keybind $Mod-Return spawn st
|
||||
hc keybind $Mod-grave spawn quake-term
|
||||
hc keybind $Mod-Control-Return spawn flatpak run org.qutebrowser.qutebrowser
|
||||
hc keybind $Mod-grave spawn $HOME/skynet/bin/quake-term
|
||||
hc keybind $Mod-Control-Return spawn firefox
|
||||
hc keybind Print spawn flameshot gui
|
||||
|
||||
hc keybind $Mod-d spawn rofi -show drun -show-icons
|
||||
|
@ -46,7 +48,7 @@ hc keybind XF86AudioPause spawn playerctl pause-pause
|
|||
hc keybind XF86AudioRaiseVolume spawn sh -c "pamixer -i 5; pamixer --get-volume >> \"$xobpipe\"; $refresh_panel"
|
||||
hc keybind XF86AudioLowerVolume spawn sh -c "pamixer -d 5; pamixer --get-volume >> \"$xobpipe\"; $refresh_panel"
|
||||
hc keybind XF86AudioMute spawn sh -c "pamixer -t; pamixer --get-volume-human | sed 's/muted/0/' >> \"$xobpipe\"; $refresh_panel"
|
||||
hc keybind $Mod-a spawn sh -c "audio-output-swap; $refresh_panel"
|
||||
hc keybind $Mod-a spawn sh -c "sh ~/skynet-old/scripts/audio-config.sh; $refresh_panel"
|
||||
hc keybind XF86Launch7 spawn sh -c "sleep 0.15 && xdotool keydown ctrl key w keyup ctrl"
|
||||
|
||||
# basic movement in tiling and floating mode
|
||||
|
@ -62,8 +64,8 @@ hc keybind $Mod-Shift-Down shift down
|
|||
hc keybind $Mod-Shift-Up shift up
|
||||
hc keybind $Mod-Shift-Right shift right
|
||||
|
||||
hc keybind $Mod-j spawn stickyctl stick
|
||||
hc keybind $Mod-Shift-j spawn stickyctl unstick
|
||||
hc keybind $Mod-j spawn ~/skynet-old/bin/stickyctl stick
|
||||
hc keybind $Mod-Shift-j spawn ~/skynet-old/bin/stickyctl unstick
|
||||
|
||||
# tags
|
||||
tag_names=( {1..9} 0 )
|
||||
|
@ -74,7 +76,7 @@ for i in "${!tag_names[@]}" ; do
|
|||
hc add "${tag_names[$i]}"
|
||||
key="${tag_keys[$i]}"
|
||||
if ! [ -z "$key" ] ; then
|
||||
hc keybind "$Mod-$key" chain , lock , use_index "$i" , spawn stickyctl get-sticky , unlock
|
||||
hc keybind "$Mod-$key" chain , lock , use_index "$i" , spawn ~/skynet-old/bin/stickyctl get-sticky , unlock
|
||||
hc keybind "$Mod-Shift-$key" move_index "$i"
|
||||
fi
|
||||
done
|
||||
|
@ -142,6 +144,7 @@ hc rule floatplacement=smart
|
|||
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' floating=on
|
||||
hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
|
||||
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
|
||||
hc rule class='nvim-zen' fullscreen=on
|
||||
hc rule class='mpv' floating=on
|
||||
|
||||
hc set tree_style '╾│ ├└╼─┐'
|
||||
|
|
|
@ -53,7 +53,7 @@ require'lspconfig'.tsserver.setup {
|
|||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
cmd = { 'npx', 'typescript-language-server', '--stdio' },
|
||||
--cmd = { 'npx', 'typescript-language-server', '--stdio' },
|
||||
}
|
||||
require'lspconfig'.yamlls.setup {
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
# If a config.py file exists, this file is ignored unless it's explicitly loaded
|
||||
# via config.load_autoconfig(). For more information, see:
|
||||
# https://github.com/qutebrowser/qutebrowser/blob/master/doc/help/configuring.asciidoc#loading-autoconfigyml
|
||||
# DO NOT edit this file by hand, qutebrowser will overwrite it.
|
||||
# Instead, create a config.py - see :help for details.
|
||||
|
||||
config_version: 2
|
||||
settings:
|
||||
bindings.commands:
|
||||
global:
|
||||
normal:
|
||||
',p': spawn --userscript qutepocket
|
||||
',m': spawn --userscript view_in_mpv
|
||||
content.canvas_reading:
|
||||
global: false
|
||||
content.geolocation:
|
||||
global: false
|
||||
content.headers.accept_language:
|
||||
global: en-US,en;q=0.5
|
||||
content.headers.custom:
|
||||
global:
|
||||
accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
|
||||
content.headers.user_agent:
|
||||
global: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0
|
||||
content.notifications.enabled:
|
||||
global: false
|
||||
spellcheck.languages:
|
||||
global:
|
||||
- en-US
|
|
@ -1,11 +0,0 @@
|
|||
import os
|
||||
|
||||
config.load_autoconfig()
|
||||
|
||||
c.colors.webpage.preferred_color_scheme = 'dark'
|
||||
c.fonts.default_size = '12pt'
|
||||
#c.zoom.default = '120%'
|
||||
|
||||
import glob
|
||||
|
||||
c.content.user_stylesheets = glob.glob(os.path.expanduser('~/.config/qutebrowser/styles/*.css'))
|
|
@ -1,52 +0,0 @@
|
|||
// ==UserScript==
|
||||
// @include /^https?://(www\.|)hckrnews\.com/.*$/
|
||||
// ==/UserScript==
|
||||
|
||||
GM_addStyle(`
|
||||
body,
|
||||
.form-actions {
|
||||
background: #242424 !important;
|
||||
color: #e3e0d7 !important;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #cae682 !important;
|
||||
}
|
||||
|
||||
.entries a.link {
|
||||
color: #e3e0d7 !important;
|
||||
}
|
||||
|
||||
.entries a.link:visited,
|
||||
.entries .source {
|
||||
color: #9c998e !important;
|
||||
}
|
||||
|
||||
.entries .homepage {
|
||||
color: #e5796d !important;
|
||||
}
|
||||
header a,
|
||||
header a:hover {
|
||||
color: #88b8f6 !important;
|
||||
}
|
||||
|
||||
.entries a:hover {
|
||||
background-color: #080808 !important;
|
||||
color: #95e454 !important;
|
||||
}
|
||||
|
||||
.entries .tab,
|
||||
.menu .nav-pills > .active > a,
|
||||
.menu .nav-pills > .active > a:hover {
|
||||
background-color: #88b8f6 !important;
|
||||
color: #080808 !important;
|
||||
}
|
||||
|
||||
.nav > li > a:hover {
|
||||
background-color: #080808 !important;
|
||||
color: #e3e0d7 !important;
|
||||
}
|
||||
|
||||
.entries .day {
|
||||
border-color: #88b8f6 !important;
|
||||
}`);
|
|
@ -1,13 +0,0 @@
|
|||
// ==UserScript==
|
||||
// @name Reddit to Libreddit Redirect
|
||||
// @namespace RedirectRedditToLibreddit
|
||||
// @description redirect reddit links to libreddit
|
||||
// @include https://www.reddit.com/
|
||||
// @include https://www.reddit.com/r/*
|
||||
// @include https://www.reddit.com/search*
|
||||
// @version 1.01
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
var newurl = window.location.href.replace(/\/\/(www\.)?reddit.com\//, '//libreddit.spike.codes/');
|
||||
window.location.replace(newurl);
|
|
@ -1,561 +0,0 @@
|
|||
// ==UserScript==
|
||||
// @name Login reminder popup remover
|
||||
// @name:it Rimuovi i popup di richiesta d'accesso
|
||||
// @namespace StephenP
|
||||
// @description Removes the nagging login popups and banners from mobile and desktop versions of Facebook, Instagram, Reddit, Twitter, Quora, Ask.fm, VK and from the mobile version of Youtube.
|
||||
// @description:it Rimuovi i fastidiosi banner e popup di richiesta d'accesso dalle versioni mobile e desktop di Facebook, Instagram, Reddit, Twitter, Quora, Ask.fm, VK e dalla versione mobile di Youtube.
|
||||
// @match https://*.facebook.com/*
|
||||
// @exclude https://developers.facebook.com/*
|
||||
// @exclude https://www.instagram.com/accounts/login/*
|
||||
// @exclude https://twitter.com/intent/tweet?*
|
||||
// @exclude https://mobile.twitter.com/intent/tweet?*
|
||||
// @match https://www.instagram.com/*
|
||||
// @match https://m.youtube.com/*
|
||||
// @match https://www.youtube.com/*
|
||||
// @match https://www.reddit.com/*
|
||||
// @match https://twitter.com/*
|
||||
// @match https://mobile.twitter.com/*
|
||||
// @match https://*.quora.com/*
|
||||
// @match https://ask.fm/*
|
||||
// @match https://vk.com/*
|
||||
// @match https://m.vk.com/*
|
||||
// @include https://www.pinterest.tld/*
|
||||
// @version 2.2.0
|
||||
// @grant none
|
||||
// @contributionURL https://nowpayments.io/donation/stephenpgreasyfork
|
||||
// @icon data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAG1BMVEXTrvFOWZTEN4aXQ6vcRGPsbUH2sVjlt7/////5Q3C9AAAAAXRSTlMAQObYZgAAANJJREFUKM+9z7EKwjAQgOFIqbPFpXMUmlHMoKsQsKtgsC9g3WMkWS2V3GN7SZrQwdl/68fdlRBCFtWac74jqYLHsvBUHjiA75lGCm6dMca6BPzg9hSzajPBcQjfbKAJFLXgTJOBqQYMqAx7pnCaDRko060W5xGhwlZk20Y4R6iIaHU3inYG3euGR3UG2b0k/lYg1AABPhLDTQoRbs7D1SYoJcTHCQZvf6PsH+H5GiEcJb0Pd0Q9wdLDXV5PdVyZRF7CYgDMz/6E9xyqdPR/sMiw+gKZRGTvTIJM4gAAAABJRU5ErkJggg==
|
||||
// ==/UserScript==
|
||||
var interval_0;
|
||||
var interval_1;
|
||||
var interval_2;
|
||||
var interval_3;
|
||||
var interval_4;
|
||||
var mutationObserver_0;
|
||||
var url;
|
||||
(function(){
|
||||
applyUserCss();
|
||||
setInterval(checkPageChanged,1000);
|
||||
})();
|
||||
function checkPageChanged(){
|
||||
if(document.location!=url){
|
||||
console.log("Changed url from "+url+" to "+document.location.toString());
|
||||
interval_4=setInterval(checkPageReady,500);
|
||||
url=document.location.toString();
|
||||
}
|
||||
}
|
||||
function applyUserCss(){//this function adds the css styling for removing popups to the head of the document, as soon as possible when the page is loaded. Other popups that can't be removed just with css selectors are removed later with the check() function
|
||||
let st=document.createElement("STYLE");
|
||||
if(document.location.href.includes("instagram.com")){
|
||||
st.textContent=".u7YqG{z-index: 1} .xUdfV{z-index: 2} ._3sb-{z-index: 3} .G_hoz.LcKDX, ._7zNgw.GLdVF{z-index: 2} .FFVAD{z-index: 1} .tWeCl{z-index: 1} .v5DqJ, .RnEpo.Yx5HN, .RnEpo._Yhr4, .xZ2Xk, .tHaIX{display: none !important} body{overflow-y: scroll !important} .CzVzU>div{z-index: 4}";
|
||||
}
|
||||
else if(document.location.href.includes("twitter.com")){
|
||||
//IF EDITING THIS LIST OF POPUPS, KEEP IT IN SYNC WITH THE POPUPS LISTED blockBannerTw
|
||||
st.textContent="#layers>.css-1dbjc4n.r-aqfbo4.r-1p0dtai.r-1d2f490.r-12vffkv.r-1xcajam.r-zchlnj>.css-1dbjc4n.r-12vffkv>.css-1dbjc4n.r-12vffkv>.css-1dbjc4n.r-l5o3uw, .css-1dbjc4n.r-1awozwy.r-14lw9ot.r-1dgieki.r-1efd50x.r-5kkj8d.r-18u37iz.r-16y2uox.r-1a1dyw.r-1swwhx3.r-1j3t67a.r-1qxgc49, .css-1dbjc4n.r-1awozwy.r-1kihuf0.r-18u37iz.r-1pi2tsx.r-1777fci.r-1pjcn9w.r-1xcajam.r-ipm5af.r-g6jmlv, .css-1dbjc4n.r-aqfbo4.r-1d2f490.r-12vffkv.r-1xcajam.r-zchlnj.r-ipm5af{display: none !important}";
|
||||
}
|
||||
else if(document.location.href.includes("reddit.com")){
|
||||
st.textContent=".m-blurred {filter: blur(0)} .XPromoNSFWBlocking__warning, .XPromoNSFWBlockingModal, .xPromoChoiceBanner, .XPromoPill, .XPromoPopup, .GetAppFooter, .XPromoInFeed, .XPromoBlockingModal, .PreviewDrawer, [data-testid=bottom-cell-wrapper]{display: none !important} .scroll-disabled {overflow-y: scroll !important; position: static !important} .NavFrame {overflow-y: scroll !important}";
|
||||
}
|
||||
else if(document.location.href.includes("quora.com/")){
|
||||
st.textContent="*, #page_wrapper {filter: none !important} .new_signup_dialog{display: none !important} .q-platform--mobile{overflow-y: scroll !important; overflow-x: hidden !important;} .q-sticky{position: inherit !important}";
|
||||
}
|
||||
else if(document.location.href.includes("https://ask.fm/")){
|
||||
st.textContent="body{overflow-y: scroll !important} .expired-countdown::after{display: none !important}";
|
||||
}
|
||||
else if(document.location.href.includes("vk.com/")){
|
||||
st.textContent="body{overflow-y: scroll !important} .PageBottomBanner--unauth{display: none !important}";
|
||||
}
|
||||
else if(document.location.href.includes("//m.youtube.com")){
|
||||
st.textContent=".upsell-dialog-lightbox{display: none !important} [modal-open-body]{position: inherit !important}";
|
||||
}
|
||||
else if(document.location.href.includes("//www.youtube.com")){
|
||||
st.textContent="ytd-guide-signin-promo-renderer{display: none !important}";
|
||||
}
|
||||
else if(document.location.href.includes("facebook.com")){
|
||||
st.textContent=".asf1osic.k4urcfbm.j9ispegn.poy2od1o.tw6a2znq.m7u2wfa4.d1544ag0.i3j981x3.rlt63pii.i09qtzwb.hybvsw6c{display: none !important}";
|
||||
if((!document.location.href.includes("m.facebook.com"))&&(!document.location.href.includes("iphone.facebook.com"))&&(!document.location.href.includes("x.facebook.com"))&&(!document.location.href.includes("touch.facebook.com"))){
|
||||
st.textContent+="#pagelet_growth_expanding_cta{display: none !important}";
|
||||
}
|
||||
else if(document.location.href.includes("touch.facebook.com")){
|
||||
st.textContent+="._4b-b{display: none !important}";
|
||||
}
|
||||
}
|
||||
else if(document.location.href.includes("quora.com")){
|
||||
st.textContent=".signup_wall_wrapper>.BaseSignupForm._DialogSignupForm{display: none !important}";
|
||||
}
|
||||
else if(document.location.href.includes("https://www.pinterest.")){
|
||||
st.textContent="[data-test-id=bottom-right-upsell], [data-test-id=giftWrap], [data-test-id=fullPageSignupModal], [data-test-id=floating-app-upsell], .FNs.XiG.zI7.iyn.Hsu{display: none !important} .article-row{-ms-overflow-style: auto !important;scrollbar-width: auto !important;} ::-webkit-scrollbar {display: block !important;} ::-webkit-scrollbar-thumb {background: grey;}";
|
||||
}
|
||||
document.getElementsByTagName("HEAD")[0].appendChild(st);
|
||||
}
|
||||
function checkPageReady(){
|
||||
if((document.getElementsByTagName("BUTTON").length>0)||(document.getElementsByTagName("FORM").length>0)||(document.getElementsByClassName("signup_login_buttons").length>0)||(document.getElementById("layers")!==null)||(document.getElementById("mcont")!==null)){//If buttons are there, the page should have loaded. At least that's what I see...
|
||||
console.log("Page is ready");
|
||||
clearInterval(interval_4);
|
||||
if(document.location.href.includes("facebook.com")){
|
||||
interval_0=setInterval(blockPopupFB,500);
|
||||
}
|
||||
else if(document.location.href.includes("instagram.com")){
|
||||
clearInterval(interval_2);
|
||||
//The following observer checks if the popup is a login popup or a suggestion to use the app: if that's not the case, the popup is displayed.
|
||||
const igPopupObserverConfig = { attributes: false, childList: true, subtree: false };
|
||||
const igPopupObserverCallback = function(mutationsList, observeIgPopups) {
|
||||
for(const mutation of mutationsList) {
|
||||
if(mutation.addedNodes.length>0){
|
||||
//console.log(mutation);
|
||||
if(mutation.addedNodes[0].classList.contains("RnEpo")){
|
||||
//console.log(!mutation.addedNodes[0].querySelector("[name='username']"));
|
||||
if((!mutation.addedNodes[0].querySelector("[name='username']"))&&(!mutation.addedNodes[0].querySelector("[href*='/accounts/login/']"))){
|
||||
let style="";
|
||||
if(mutation.addedNodes[0].hasAttribute("style")){
|
||||
style=mutation.addedNodes[0].getAttribute("style");
|
||||
}
|
||||
mutation.addedNodes[0].setAttribute("style","display: block !important;"+style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const observeIgPopups = new MutationObserver(igPopupObserverCallback);
|
||||
observeIgPopups.observe(document.body, igPopupObserverConfig);
|
||||
|
||||
//interval_1=setInterval(blockBannerIG,200);
|
||||
if((document.location.href.includes('instagram.com/p/'))||(document.location.href.includes('instagram.com/tv/'))||(document.location.href.includes('/reel/'))){
|
||||
if((document.location.href.includes('/tv/'))){
|
||||
let igtvVideo=document.getElementsByTagName("VIDEO")[0];
|
||||
let cln=igtvVideo.cloneNode(true);
|
||||
insertAfter(cln,igtvVideo);
|
||||
igtvVideo.remove();
|
||||
}
|
||||
interval_0=setInterval(allowVideoReplayStarterIG,500);
|
||||
}
|
||||
else if(document.location.href.includes('/channel')){
|
||||
if(document.getElementsByClassName("coreSpriteSearchIcon").length>0){//only desktop version shows login popup on igtv
|
||||
interval_2=setInterval(removePicturePopupIGTV,1000);
|
||||
}
|
||||
}
|
||||
else if((document.location.href.includes('/reels/'))||
|
||||
(document.location.href.includes('/guides/'))||
|
||||
(document.location.href.includes('/guide/'))){
|
||||
//do nothing;
|
||||
}
|
||||
else{//this should ideally only include the main page of the profile
|
||||
//interval_2=setInterval(blockPopupIG,200);
|
||||
let sectionLinks=document.getElementsByClassName("_9VEo1");
|
||||
for(let sectionLink of sectionLinks){
|
||||
if(sectionLink.href.includes("%2Ffeed%2F")){
|
||||
let tmpSectionLink=sectionLink.cloneNode(true);
|
||||
tmpSectionLink.href=document.location.href+"feed/";
|
||||
sectionLink=sectionLink.parentNode.replaceChild(tmpSectionLink,sectionLink);
|
||||
break;
|
||||
}
|
||||
}
|
||||
interval_3=setInterval(removeRelatedAccounts,200);
|
||||
interval_2=setInterval(removePicturePopup,500);
|
||||
}
|
||||
}
|
||||
else if(document.location.href.includes("reddit.com")){//reddit has a wide range of different login reminders for installing the app or logging in when browsing from a phone
|
||||
if(document.getElementsByClassName("TopNav__promoButton").length>0){
|
||||
var isMobile=true;
|
||||
if(document.getElementsByClassName("MobileButton").length==0){
|
||||
isMobile=false;
|
||||
}
|
||||
redditPatch(isMobile);
|
||||
}
|
||||
}
|
||||
else if(document.location.href.includes("quora.com/")){
|
||||
quoraPatchObserver();
|
||||
}
|
||||
else if(document.location.href.includes("/twitter.com")){
|
||||
blockBannerTW("d");
|
||||
}
|
||||
else if(document.location.href.includes("mobile.twitter.com")){
|
||||
blockBannerTW("m");
|
||||
}
|
||||
else if(document.location.href.includes("https://ask.fm/")){
|
||||
removeAskFmLoginPopup();
|
||||
}
|
||||
else if(document.location.href.includes("https://vk.com/")){
|
||||
checkVKLoginPopup("d");
|
||||
}
|
||||
else if(document.location.href.includes("https://m.vk.com/")){
|
||||
checkVKLoginPopup("m");
|
||||
}
|
||||
else if(document.location.href.includes("https://www.pinterest.")){
|
||||
document.body.setAttribute("style", "overflow-y: auto !important");
|
||||
}
|
||||
}
|
||||
else{
|
||||
console.log("still non buttons");
|
||||
}
|
||||
}
|
||||
function blockPopupFB(){
|
||||
var popupFB;
|
||||
var loc=document.location.href;
|
||||
if((loc.includes("m.facebook.com"))||(loc.includes("iphone.facebook.com"))||(loc.includes("x.facebook.com"))){
|
||||
popupFB=document.getElementById("popup_xout").parentNode.parentNode.parentNode;
|
||||
}
|
||||
if(popupFB==undefined){
|
||||
popupFB=document.getElementsByClassName("_5hn6")[0];
|
||||
if(popupFB==undefined){
|
||||
popupFB=document.getElementById("login_popup_cta_form").parentNode.parentNode.parentNode.parentNode;
|
||||
let scrollview=document.getElementById("scrollview");
|
||||
scrollview.parentNode.lastChild.remove();
|
||||
scrollview.style.scrollbarWidth="auto";
|
||||
document.getElementsByClassName("asf1osic k4urcfbm j9ispegn poy2od1o tw6a2znq m7u2wfa4 d1544ag0 i3j981x3 rlt63pii i09qtzwb hybvsw6c")[0].remove();
|
||||
}
|
||||
}
|
||||
if(popupFB!==undefined){
|
||||
popupFB.parentNode.removeChild(popupFB);
|
||||
clearInterval(interval_0);
|
||||
}
|
||||
}
|
||||
function removeRelatedAccounts(){
|
||||
//var t0=performance.now();
|
||||
let morePostsBtn=document.getElementsByClassName('tCibT qq7_A z4xUb w5S7h')[0];
|
||||
if(morePostsBtn!==undefined){
|
||||
morePostsBtn.click();
|
||||
clearInterval(interval_3);
|
||||
}
|
||||
else{
|
||||
var closeButtons=document.getElementsByClassName("fUzmR");
|
||||
if(closeButtons.length>0){
|
||||
for(var i=0;i<closeButtons.length;i++){
|
||||
//closeButtons[i].click();
|
||||
}
|
||||
clearInterval(interval_3);
|
||||
}
|
||||
}
|
||||
//var t1=performance.now();
|
||||
//alert(t1-t0);
|
||||
}
|
||||
function removePicturePopup(){
|
||||
console.log("removing picture popup");
|
||||
if(!document.location.href.includes("/p/")){
|
||||
var photoLinks=document.getElementsByClassName("v1Nh3");
|
||||
for(var i=0;i<photoLinks.length;i++){
|
||||
if(photoLinks[i].getAttribute("class").includes("repaired")===false){
|
||||
if(photoLinks[i].getElementsByTagName("IMG")[0].getAttribute("src")!==null){
|
||||
var cln = photoLinks[i].children[0].cloneNode(true);
|
||||
photoLinks[i].removeChild(photoLinks[i].children[0]);
|
||||
photoLinks[i].appendChild(cln);
|
||||
photoLinks[i].setAttribute("class",(photoLinks[i].getAttribute("class")+" repaired"));
|
||||
photoLinks[i].children[0].setAttribute("target","_blank");
|
||||
photoLinks[i].children[0].setAttribute("rel","noopener noreferrer");
|
||||
photoLinks[i].children[0].children[0].children[0].children[0].style.visibility="visible";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function removePicturePopupIGTV(){
|
||||
console.log("removing picture popup from igtv");
|
||||
if(!document.location.href.includes("/tv/")){
|
||||
var videoLinks=document.getElementsByClassName("_bz0w");
|
||||
for(var i=0;i<videoLinks.length;i++){
|
||||
if(videoLinks[i].getAttribute("class").includes("repaired")===false){
|
||||
if(videoLinks[i].getElementsByClassName("lVhHa RNL1l")[0].style.backgroundSrc!==null){
|
||||
var cln = videoLinks[i].cloneNode(true);
|
||||
cln.setAttribute("class",(videoLinks[i].getAttribute("class")+" repaired"));
|
||||
insertAfter(cln,videoLinks[i]);
|
||||
videoLinks[i].remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function insertAfter(newNode, existingNode) {
|
||||
existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);
|
||||
}
|
||||
|
||||
/*function blockPopupIG(){ //kept for reference
|
||||
if(document.getElementsByClassName("RnEpo")[0]!==undefined){
|
||||
setScrollable();
|
||||
}
|
||||
}*/
|
||||
/*function setScrollable(){ //kept for reference
|
||||
document.body.style.overflow = "scroll !important";
|
||||
}*/
|
||||
function blockBannerTW(s){
|
||||
/*if(s=='d'){
|
||||
document.getElementsByClassName("css-1dbjc4n r-16y2uox r-1n0xq6e")[0].parentNode.parentNode.parentNode.parentNode.remove();
|
||||
}
|
||||
else{
|
||||
var banner=document.getElementsByClassName("css-1dbjc4n r-1awozwy r-1pz39u2 r-18u37iz r-16y2uox")[0].parentNode;
|
||||
if(banner!=='undefined'){
|
||||
banner.parentNode.style.height="53px";
|
||||
banner.remove();
|
||||
}
|
||||
banner=document.getElementsByClassName("css-1dbjc4n r-urgr8i r-97e31f")[0];
|
||||
if(banner!=='undefined'){
|
||||
banner.remove();
|
||||
}
|
||||
}*/
|
||||
if(mutationObserver_0===undefined){
|
||||
function callback_a(mutationList) {
|
||||
mutationList.forEach(function(mutation) {
|
||||
let largeLP;
|
||||
//IF EDITING THIS LIST OF POPUPS, KEEP IT IN SYNC WITH THE POPUPS LISTED IN CUSTOM CSS
|
||||
largeLP=document.querySelector(".css-1dbjc4n.r-aqfbo4.r-1d2f490.r-12vffkv.r-1xcajam.r-zchlnj.r-ipm5af");//big login popup triggered when clicking on "like" or "comment" (mobile)
|
||||
if(largeLP===null){
|
||||
largeLP=document.querySelector(".css-1dbjc4n.r-1awozwy.r-1kihuf0.r-18u37iz.r-1pi2tsx.r-1777fci.r-1pjcn9w.r-1xcajam.r-ipm5af.r-g6jmlv");//big login popup triggered when clicking on "like" or "comment" (desktop);
|
||||
}
|
||||
if(largeLP===null){
|
||||
largeLP=document.querySelector(".css-1dbjc4n.r-1awozwy.r-14lw9ot.r-1dgieki.r-1efd50x.r-5kkj8d.r-18u37iz.r-16y2uox.r-1a1dyw.r-1swwhx3.r-1j3t67a.r-1qxgc49");//another popup (i don't remember which one)
|
||||
}
|
||||
if(largeLP===null){
|
||||
largeLP=document.querySelector("#layers>.css-1dbjc4n.r-aqfbo4.r-1p0dtai.r-1d2f490.r-12vffkv.r-1xcajam.r-zchlnj>.css-1dbjc4n.r-12vffkv>.css-1dbjc4n.r-12vffkv>.css-1dbjc4n.r-l5o3uw");//another popup (i don't remember which one)
|
||||
}
|
||||
if(largeLP!==null){
|
||||
if(mutation.target.style.overflow=="hidden"){//definitely not the right way to do it, but setting the style attributes with mutation.target.style doesn't work.
|
||||
let restyle=mutation.target.getAttribute("style");
|
||||
restyle=restyle.replace("overflow: hidden","overflow: auto scroll");
|
||||
restyle=restyle.replace("margin-right: 17px","margin-right: auto");
|
||||
restyle=restyle.replace("overscroll-behavior-y: none;","overscroll-behavior-y: auto");
|
||||
restyle=restyle.replace("position: fixed","position: unset");
|
||||
mutation.target.setAttribute("style",restyle);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
mutationObserver_0 = new MutationObserver(callback_a);
|
||||
mutationObserver_0.observe(document.documentElement, {attributes: true});
|
||||
}
|
||||
}
|
||||
function redditPatch(isMobile){
|
||||
const nav=document.getElementsByClassName("NavFrame__below-top-nav")[0];
|
||||
const config = { attributes: false, childList: true, subtree: true };
|
||||
var firstCheck=true;
|
||||
var redditPic=document.body.getElementsByTagName("IMG");
|
||||
const callback = function(mutationsList, observer) {
|
||||
for(const mutation of mutationsList) {
|
||||
if(isMobile){
|
||||
let articles=mutation.target.getElementsByTagName("ARTICLE");
|
||||
if(articles.length>0){
|
||||
for (const article of articles){
|
||||
if(!article.classList.contains("replaced")){
|
||||
if((article.getElementsByTagName("video").length==0)&&(article.getElementsByClassName("slideImageMainDiv").length==0)){
|
||||
var articleCopy=article.cloneNode(true);
|
||||
articleCopy.classList.add("replaced");
|
||||
article.replaceWith(articleCopy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(firstCheck==false){
|
||||
redditPic=mutation.target.getElementsByTagName("IMG");
|
||||
}
|
||||
if(redditPic.length>0){
|
||||
for(var i=0;i<redditPic.length;i++){
|
||||
if((redditPic[i].getAttribute("src").includes("blur="))&&(redditPic[i].getAttribute("src").includes("/preview."))){
|
||||
redditPic[i].setAttribute("src",redditPic[i].getAttribute("src").split("?")[0].replace("preview","i"));
|
||||
}
|
||||
}
|
||||
firstCheck=false;
|
||||
}
|
||||
}
|
||||
};
|
||||
const bodyObserver = new MutationObserver(callback);
|
||||
bodyObserver.observe(nav, config);
|
||||
}
|
||||
function quoraPatchObserver(){
|
||||
var firstCheck=true;
|
||||
var searchBox=document.createElement("DIV");
|
||||
searchBox.className="q-flex qu-alignItems--center qu-justifyContent--center";
|
||||
searchBox.style="box-sizing: border-box; display: flex; max-width: 100%;";
|
||||
let a=document.createElement("INPUT");
|
||||
a.id="search";
|
||||
a.style="height: 44px; text-align: center; border-radius: 22px; background-color:white; width: 100%; margin: 0.5em";
|
||||
a.className="selector_input text";
|
||||
a.value="";
|
||||
a.setAttribute("data-lpignore","true");
|
||||
a.setAttribute("data-group","js-editable");
|
||||
a.setAttribute("placeholder","Search");
|
||||
a.setAttribute("w2cid","wS7KcEIg18");
|
||||
searchBox.appendChild(a);
|
||||
searchBox.addEventListener('keypress', function(e){searchQuora(e);});
|
||||
try{
|
||||
document.getElementsByClassName("q-sticky qu-zIndex--header")[0].appendChild(searchBox);
|
||||
}
|
||||
catch(e){
|
||||
try{
|
||||
document.getElementsByClassName("header_main")[0].appendChild(searchBox);
|
||||
document.getElementsByClassName("query_title")[0].style.marginTop="2em";
|
||||
}catch(err){console.log("Info: if you are browsing from a PC, this error is expected.");}
|
||||
}
|
||||
quoraPatch(firstCheck);
|
||||
firstCheck=false;
|
||||
const config = { attributes: true, childList: true, subtree: false };//this rough implementation is slower
|
||||
const callback = function(mutationsList, observer) {
|
||||
for(const mutation of mutationsList) {
|
||||
quoraPatch(firstCheck);
|
||||
}
|
||||
};
|
||||
const bodyObserver = new MutationObserver(callback);
|
||||
bodyObserver.observe(document.body, config);
|
||||
}
|
||||
function quoraPatch(firstCheck){
|
||||
var i;
|
||||
var wall;
|
||||
if(firstCheck==true){
|
||||
wall=document.getElementsByClassName("q-box qu-overflow--hidden");
|
||||
if(wall.length>1){
|
||||
let bgColor=getComputedStyle(wall[0].parentNode.children[0]).backgroundColor;
|
||||
if(bgColor=="rgba(68, 68, 68, 0.85)"){
|
||||
wall[0].parentNode.children[0].remove();
|
||||
wall[0].classList.remove("qu-overflow--hidden");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(document.body.className.includes('signup_wall_prevent_scroll')){
|
||||
document.body.classList.remove('signup_wall_prevent_scroll');
|
||||
}
|
||||
wall=document.getElementsByClassName('new_web_signup_wall_design');
|
||||
if(wall.length>0){
|
||||
wall[0].parentNode.parentNode.remove();//desktop
|
||||
}
|
||||
wall=document.getElementsByClassName('modal_bg new_signup_dialog');
|
||||
if(wall.length>0){
|
||||
wall[0].parentNode.remove();//mobile
|
||||
}
|
||||
wall=document.getElementsByClassName('q-absolute qu-full qu-bg--blue');
|
||||
if(wall.length>0){
|
||||
wall[0].parentNode.remove();//mobile
|
||||
}
|
||||
}
|
||||
function searchQuora(e) {
|
||||
if (e.key === 'Enter') {
|
||||
window.open("https://www.quora.com/search?q="+document.getElementById("search").value,"_self");
|
||||
}
|
||||
}
|
||||
function removeAskFmLoginPopup(){
|
||||
try{
|
||||
const closeButton=document.createElement("DIV");
|
||||
closeButton.id="closeButton";
|
||||
closeButton.style.padding="1em";
|
||||
closeButton.style.right="1em";
|
||||
closeButton.style.top="1em";
|
||||
closeButton.style.position="absolute";
|
||||
closeButton.textContent="X";
|
||||
closeButton.style.borderRadius="3px";
|
||||
closeButton.style.backgroundColor="#666666";
|
||||
closeButton.style.color="#FFFFFF";
|
||||
closeButton.style.cursor="pointer";
|
||||
closeButton.addEventListener("click",function(e){document.getElementsByClassName("lightbox_overlay")[0].remove();});
|
||||
var lightbox=document.getElementsByClassName("lightbox_overlay");
|
||||
console.log(lightbox.length);
|
||||
if(lightbox.length>0){
|
||||
if(lightbox[0].getElementsByClassName("lightbox_content-conversion").length>0){
|
||||
lightbox[0].parentNode.removeChild(lightbox[0]);
|
||||
}
|
||||
}
|
||||
const callback = function(mutationsList, observer) {
|
||||
for(const mutation of mutationsList) {
|
||||
console.log("A");
|
||||
for(let newNode of mutation.addedNodes){
|
||||
if(newNode.className.includes("lightbox_overlay")){
|
||||
if(newNode.getElementsByClassName("lightbox_content-conversion").length>0){
|
||||
console.log("popup deleted");
|
||||
newNode.parentNode.removeChild(newNode);
|
||||
}
|
||||
else{
|
||||
newNode.appendChild(closeButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const config = { attributes: false, childList: true, subtree: true };
|
||||
const observer = new MutationObserver(callback);
|
||||
observer.observe(document.documentElement, config);
|
||||
}
|
||||
catch(err){console.log("ERROR: "+err);}
|
||||
}
|
||||
function checkVKLoginPopup(mode){
|
||||
const popups=document.getElementsByClassName("UnauthActionBoxContainer");
|
||||
if(popups.length>0){
|
||||
removeVKLoginPopup(popups[0]);
|
||||
}
|
||||
const config = { attributes: false, childList: true, subtree: false };
|
||||
const callback = function(mutationsList, observer) {
|
||||
for(const mutation of mutationsList) {
|
||||
for(let newNode of mutation.addedNodes){
|
||||
if(newNode.className.includes("UnauthActionBoxContainer")){
|
||||
removeVKLoginPopup(newNode,mode);
|
||||
}
|
||||
else if(newNode.getElementsByClassName("UnauthorizedActionModal")!==undefined){
|
||||
removeVKLoginPopup(newNode,mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const observer = new MutationObserver(callback);
|
||||
if(mode=="d"){
|
||||
observer.observe(document.getElementById("box_layer"), config);
|
||||
}
|
||||
else{
|
||||
observer.observe(document.body, config);
|
||||
}
|
||||
}
|
||||
function removeVKLoginPopup(popup,mode){
|
||||
popup.remove();
|
||||
console.log("Popup removed");
|
||||
if(mode=="d"){
|
||||
document.getElementById("box_layer_bg").remove();
|
||||
document.getElementById("box_layer_wrap").remove();
|
||||
}
|
||||
else{
|
||||
document.getElementById("popup_wrap").remove();
|
||||
document.getElementById("popup_overlay").remove();
|
||||
}
|
||||
}
|
||||
function allowVideoReplayStarterIG(){
|
||||
var imgBox=document.getElementsByClassName("pR7Pc");
|
||||
if(imgBox.length>0){
|
||||
let videoPlayer=imgBox[0].getElementsByTagName("VIDEO");
|
||||
if(videoPlayer.length>0){
|
||||
let moveTagCss=document.createElement("style");
|
||||
moveTagCss.textContent=".LcKDX, ._7zNgw.GLdVF {bottom: 3em}";
|
||||
document.body.appendChild(moveTagCss);
|
||||
for (let vp of videoPlayer){
|
||||
vp.controls=true;
|
||||
}
|
||||
}
|
||||
allowVideoReplayIG(imgBox[0]);
|
||||
clearInterval(interval_0);
|
||||
}
|
||||
else{
|
||||
imgBox=document.getElementsByClassName("kPFhm B1JlO OAXCp");
|
||||
if(imgBox.length>0){
|
||||
let videoPlayer=imgBox[0].getElementsByTagName("VIDEO");
|
||||
if(videoPlayer.length>0){
|
||||
let moveTagCss=document.createElement("style");
|
||||
moveTagCss.textContent=".LcKDX, ._7zNgw.GLdVF {bottom: 3em}";
|
||||
document.body.appendChild(moveTagCss);
|
||||
for (let vp of videoPlayer){
|
||||
vp.controls=true;
|
||||
}
|
||||
}
|
||||
allowVideoReplayIG(imgBox[0]);
|
||||
clearInterval(interval_0);
|
||||
}
|
||||
}
|
||||
}
|
||||
function allowVideoReplayIG(imgBox){
|
||||
console.log("add video controls");
|
||||
const config = { attributes: false, childList: true, subtree: true };
|
||||
const callback = function(mutationsList, observer) {
|
||||
for(const mutation of mutationsList) {
|
||||
for(let newNode of mutation.addedNodes){
|
||||
let videoPlayer=newNode.getElementsByTagName("VIDEO");
|
||||
if(videoPlayer.length>0){
|
||||
for (var vp of videoPlayer){
|
||||
vp.controls=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const observer = new MutationObserver(callback);
|
||||
observer.observe(imgBox, config);
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
// ==UserScript==
|
||||
// @include /^https?://news\.ycombinator\.com/.*$/
|
||||
// ==/UserScript==
|
||||
|
||||
GM_addStyle(`
|
||||
body {
|
||||
background-color: #080808 !important;
|
||||
color: #e3e0d7 !important;
|
||||
}
|
||||
|
||||
#hnmain {
|
||||
background-color: #242424 !important;
|
||||
}
|
||||
|
||||
#hnmain td[bgcolor='#ff6600'] {
|
||||
background-color: #88b8f6 !important;
|
||||
}
|
||||
|
||||
img[src='y18.gif'] {
|
||||
filter: invert(100%) !important;
|
||||
}
|
||||
|
||||
#hnmain td[bgcolor='#ff6600'] a:link {
|
||||
color: #080808 !important;
|
||||
}
|
||||
|
||||
.comhead a:link,
|
||||
.subtext a:visited,
|
||||
.hnmore a:link,
|
||||
a:visited {
|
||||
color: #9c998e !important;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #e3e0d7 !important;
|
||||
}
|
||||
|
||||
a.storylink:hover {
|
||||
color: #cae682 !important;
|
||||
}
|
||||
|
||||
font[color='#3c963c'] {
|
||||
color: #95e454 !important;
|
||||
}
|
||||
|
||||
.c00,
|
||||
.c00 a:link {
|
||||
color: #e3e0d7 !important;
|
||||
}
|
||||
|
||||
.c5a,
|
||||
.c5a a:link,
|
||||
.c5a a:visited,
|
||||
.c73,
|
||||
.c73 a:link,
|
||||
.c73 a:visited,
|
||||
.c82,
|
||||
.c82 a:link,
|
||||
.c82 a:visited,
|
||||
.c88,
|
||||
.c88 a:link,
|
||||
.c88 a:visited,
|
||||
.c9c,
|
||||
.c9c a:link,
|
||||
.c9c a:visited,
|
||||
.cae,
|
||||
.cae a:link,
|
||||
.cae a:visited,
|
||||
.cbe,
|
||||
.cbe a:link,
|
||||
.cbe a:visited,
|
||||
.cce,
|
||||
.cce a:link,
|
||||
.cce a:visited,
|
||||
.cdd,
|
||||
.cdd a:link,
|
||||
.cdd a:visited {
|
||||
color: #e5796d !important;
|
||||
}
|
||||
|
||||
.comment,
|
||||
.title {
|
||||
font-size: 12pt !important;
|
||||
}`);
|
|
@ -1,114 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (c) 2017 Ondřej Kudlík (Kepi), https://kepi.cz
|
||||
|
||||
# qutepocket is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutepocket is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
|
||||
from pocket import Pocket, PocketAutException, PocketException
|
||||
|
||||
CONSUMER_KEY = "70250-26f8e47a9dba2989767f4512"
|
||||
REDIRECT_URI = "https://github.com/kepi/qutepocket/wiki/Authorized"
|
||||
|
||||
SECRET = os.environ['QUTE_CONFIG_DIR'] + '/qutepocket.secrets'
|
||||
REQUEST = os.environ['QUTE_CONFIG_DIR'] + '/qutepocket.request'
|
||||
|
||||
FIFO = open(os.environ['QUTE_FIFO'], 'w')
|
||||
|
||||
|
||||
def command(command):
|
||||
FIFO.write(command + "\n")
|
||||
|
||||
|
||||
def get_request_token():
|
||||
request_token = pocket.get_request_token(REDIRECT_URI)
|
||||
|
||||
if not request_token:
|
||||
exit(11)
|
||||
|
||||
with open(REQUEST, 'w') as request_file:
|
||||
request_file.write(request_token)
|
||||
|
||||
auth_url = ("https://getpocket.com/auth/authorize"
|
||||
"?request_token={0}"
|
||||
"&redirect_uri={1}"
|
||||
).format(request_token, REDIRECT_URI)
|
||||
|
||||
msg = ("Accept access, close opened page and use "
|
||||
"Save to Pocket command again.")
|
||||
|
||||
command('open -t %s' % auth_url)
|
||||
command('message-info "%s"' % msg)
|
||||
exit(0)
|
||||
|
||||
|
||||
def get_access_token():
|
||||
try:
|
||||
with open(REQUEST) as request_file:
|
||||
request_token = request_file.read()
|
||||
|
||||
access_token = pocket.get_access_token(request_token)
|
||||
print(access_token)
|
||||
with open(SECRET, 'w') as request_file:
|
||||
request_file.write(access_token)
|
||||
os.remove(REQUEST)
|
||||
|
||||
msg = "Congratulation, qutepocket is authorized now :)"
|
||||
command('message-info "%s"' % msg)
|
||||
|
||||
except PocketAutException:
|
||||
os.remove(REQUEST)
|
||||
get_request_token()
|
||||
exit(12)
|
||||
|
||||
|
||||
def reauthorize():
|
||||
command('message-warning "Invalid secret token, trying to reauthorize."')
|
||||
if os.path.isfile(SECRET):
|
||||
os.remove(SECRET)
|
||||
|
||||
get_request_token()
|
||||
|
||||
|
||||
def add():
|
||||
try:
|
||||
pocket.add(os.environ['QUTE_URL'], os.environ['QUTE_TITLE'])
|
||||
command('message-info "Great, page is in your Pocket."')
|
||||
|
||||
except PocketException as e:
|
||||
# secret token e
|
||||
if e.error_code == 107:
|
||||
reauthorize()
|
||||
|
||||
else:
|
||||
command('message-warning "Error while Pocketing the page: %s %s"'
|
||||
% (e.message, e.error_code))
|
||||
|
||||
|
||||
if not os.path.isfile(SECRET):
|
||||
access_token = ""
|
||||
pocket = Pocket(CONSUMER_KEY, access_token)
|
||||
|
||||
if os.path.isfile(REQUEST):
|
||||
get_access_token()
|
||||
else:
|
||||
get_request_token()
|
||||
|
||||
with open(SECRET) as secrets_file:
|
||||
access_token = secrets_file.read()
|
||||
pocket = Pocket(CONSUMER_KEY, access_token)
|
||||
add()
|
||||
|
||||
FIFO.close()
|
|
@ -1,143 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Behavior:
|
||||
# Userscript for qutebrowser which views the current web page in mpv using
|
||||
# sensible mpv-flags. While viewing the page in MPV, all <video>, <embed>,
|
||||
# and <object> tags in the original page are temporarily removed. Clicking on
|
||||
# such a removed video restores the respective video.
|
||||
#
|
||||
# In order to use this script, just start it using `spawn --userscript` from
|
||||
# qutebrowser. I recommend using an alias, e.g. put this in the
|
||||
# [alias]-section of qutebrowser.conf:
|
||||
#
|
||||
# mpv = spawn --userscript /path/to/view_in_mpv
|
||||
#
|
||||
# Background:
|
||||
# Most of my machines are too slow to play youtube videos using html5, but
|
||||
# they work fine in mpv (and mpv has further advantages like video scaling,
|
||||
# etc). Of course, I don't want the video to be played (or even to be
|
||||
# downloaded) twice — in MPV and in qwebkit. So I often close the tab after
|
||||
# opening it in mpv. However, I actually want to keep the rest of the page
|
||||
# (comments and video suggestions), i.e. only the videos should disappear
|
||||
# when mpv is started. And that's precisely what the present script does.
|
||||
#
|
||||
# Thorsten Wißmann, 2015 (thorsten` on Libera Chat)
|
||||
# Any feedback is welcome!
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$QUTE_FIFO" ] ; then
|
||||
cat 1>&2 <<EOF
|
||||
Error: $0 can not be run as a standalone script.
|
||||
|
||||
It is a qutebrowser userscript. In order to use it, call it using
|
||||
'spawn --userscript' as described in qute://help/userscripts.html
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg() {
|
||||
local cmd="$1"
|
||||
shift
|
||||
local msg="$*"
|
||||
if [ -z "$QUTE_FIFO" ] ; then
|
||||
echo "$cmd: $msg" >&2
|
||||
else
|
||||
echo "message-$cmd '${msg//\'/\\\'}'" >> "$QUTE_FIFO"
|
||||
fi
|
||||
}
|
||||
|
||||
MPV_COMMAND=${MPV_COMMAND:-mpv}
|
||||
# Warning: spaces in single flags are not supported
|
||||
MPV_FLAGS=${MPV_FLAGS:- --force-window --no-terminal --keep-open=yes --ytdl}
|
||||
IFS=" " read -r -a video_command <<< "$MPV_COMMAND $MPV_FLAGS"
|
||||
|
||||
js() {
|
||||
cat <<EOF
|
||||
|
||||
function descendantOfTagName(child, ancestorTagName) {
|
||||
// tells whether child has some (proper) ancestor
|
||||
// with the tag name ancestorTagName
|
||||
while (child.parentNode != null) {
|
||||
child = child.parentNode;
|
||||
if (typeof child.tagName === 'undefined') break;
|
||||
if (child.tagName.toUpperCase() == ancestorTagName.toUpperCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var App = {};
|
||||
|
||||
var all_videos = [];
|
||||
all_videos.push.apply(all_videos, document.getElementsByTagName("video"));
|
||||
all_videos.push.apply(all_videos, document.getElementsByTagName("object"));
|
||||
all_videos.push.apply(all_videos, document.getElementsByTagName("embed"));
|
||||
App.backup_videos = Array();
|
||||
App.all_replacements = Array();
|
||||
for (i = 0; i < all_videos.length; i++) {
|
||||
var video = all_videos[i];
|
||||
if (descendantOfTagName(video, "object")) {
|
||||
// skip tags that are contained in an object, because we hide
|
||||
// the object anyway.
|
||||
continue;
|
||||
}
|
||||
var replacement = document.createElement("div");
|
||||
replacement.innerHTML = "
|
||||
<p style=\\"margin-bottom: 0.5em\\">
|
||||
Opening page with:
|
||||
<span style=\\"font-family: monospace;\\">${video_command[*]}</span>
|
||||
</p>
|
||||
<p>
|
||||
In order to restore this particular video
|
||||
<a style=\\"font-weight: bold;
|
||||
color: white;
|
||||
background: transparent;
|
||||
\\"
|
||||
onClick=\\"restore_video(this, " + i + ");\\"
|
||||
href=\\"javascript: restore_video(this, " + i + ")\\"
|
||||
>click here</a>.
|
||||
</p>
|
||||
";
|
||||
replacement.style.position = "relative";
|
||||
replacement.style.zIndex = "100003000000";
|
||||
replacement.style.fontSize = "1rem";
|
||||
replacement.style.textAlign = "center";
|
||||
replacement.style.verticalAlign = "middle";
|
||||
replacement.style.height = "100%";
|
||||
replacement.style.background = "#101010";
|
||||
replacement.style.color = "white";
|
||||
replacement.style.border = "4px dashed #545454";
|
||||
replacement.style.padding = "2em";
|
||||
replacement.style.margin = "auto";
|
||||
App.all_replacements[i] = replacement;
|
||||
App.backup_videos[i] = video;
|
||||
video.parentNode.replaceChild(replacement, video);
|
||||
}
|
||||
|
||||
function restore_video(obj, index) {
|
||||
obj = App.all_replacements[index];
|
||||
video = App.backup_videos[index];
|
||||
console.log(video);
|
||||
obj.parentNode.replaceChild(video, obj);
|
||||
}
|
||||
|
||||
/** force repainting the video, thanks to:
|
||||
* http://web.archive.org/web/20151029064649/https://martinwolf.org/2014/06/10/force-repaint-of-an-element-with-javascript/
|
||||
*/
|
||||
var siteHeader = document.getElementById('header');
|
||||
siteHeader.style.display='none';
|
||||
siteHeader.offsetHeight; // no need to store this anywhere, the reference is enough
|
||||
siteHeader.style.display='block';
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
printjs() {
|
||||
js | sed 's,//.*$,,' | tr '\n' ' '
|
||||
}
|
||||
echo "jseval -q $(printjs)" >> "$QUTE_FIFO"
|
||||
|
||||
msg info "Opening $QUTE_URL with mpv"
|
||||
"${video_command[@]}" "$@" "$QUTE_URL"
|
|
@ -16,15 +16,15 @@ export PATH=$PATH:~/skynet/bin:~/node/node_modules/.bin:~/.local/bin:~/go/bin:~/
|
|||
export EDITOR=vim
|
||||
export PAGER=bat
|
||||
export MANPAGER=batman
|
||||
export BROWSER=qutebrowser
|
||||
export BAT_THEME='Wombat'
|
||||
export DOTNET_ROOT=~/.dotnet
|
||||
export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
|
||||
export GPG_TTY=$(tty)
|
||||
export NNN_PLUG='d:dragdrop;i:imgview'
|
||||
export NNN_PREVIEWDIR='~/.cache/nnn/previews'
|
||||
|
||||
alias ls='exa --icons'
|
||||
alias cat='bat'
|
||||
alias flatpak='flatpak --user'
|
||||
alias cd..='cd ..'
|
||||
alias j='goto'
|
||||
alias jqize="jq -R -r '. as \$line | try fromjson catch \$line'"
|
||||
|
@ -41,5 +41,6 @@ alias duskh="du -hka --max-depth=1 | sort -h"
|
|||
alias 8bitdo="xboxdrv --evdev /dev/btjoy --config ~/.config/xboxdrv/8bitdo.conf"
|
||||
alias ddev="export COMPOSE_FILE=docker-compose.dev.yaml"
|
||||
alias penscreen="xsetwacom set 'Wacom Intuos PT S Pen stylus' MapToOutput HEAD-1; xsetwacom set 'Wacom Intuos PT S Pen eraser' MapToOutput HEAD-1"
|
||||
alias connected="ss -O4Hpr -tun state connected"
|
||||
|
||||
test -e ~/.bash_aliases && source ~/.bash_aliases
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||
*/
|
||||
static char *font = "monospace:pixelsize=18:antialias=true:autohint=true";
|
||||
static char *font = "monospace:pixelsize=16:antialias=true:autohint=true";
|
||||
static int borderpx = 2;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue