diff --git a/misc/userscripts/view_in_mpv b/misc/userscripts/view_in_mpv new file mode 100755 index 000000000..caa95ea8f --- /dev/null +++ b/misc/userscripts/view_in_mpv @@ -0,0 +1,109 @@ +#!/bin/bash -e +# +# Behaviour: +# Userscript for qutebrowser which views the current web page in mpv using +# sensible mpv-flags. While viewing the page in MPV, all
++ In order to restore this particular video + click here. +
+ "; + replacement.style.position = "relative"; + replacement.style.zIndex = "1000"; + 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://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 "Openning $QUTE_URL with mpv" +"${video_command[@]}" "$QUTE_URL"