summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2023-08-20 10:42:43 +1200
committertoofar <toofar@spalge.com>2023-08-20 10:57:14 +1200
commitd4a7619f9c51db56016ab710ee007239d1733fc7 (patch)
treef28d96c4de8c80bc615d96939577edcbb60faf7c
parentd5b5f2699688e3719eab7606c54ac277dcfaf2cb (diff)
downloadqutebrowser-d4a7619f9c51db56016ab710ee007239d1733fc7.tar.gz
qutebrowser-d4a7619f9c51db56016ab710ee007239d1733fc7.zip
userscripts: run view_in_mpv jseval in main world
1. run jseval in main world: the script adds an element that calls the `restore_video` function. This was failing with a "not found" message on webengine, presumably because the dom click handler runs in the main world and the function was over in the jseval world. The the script predates webengine which is the backend that implements the worlds. 2. remove a console log message, seems to be just noise and easy enough to add back later 3. remove href attribute of the restore video link: this seemed to be causing the `restore_video` method to be called twice. The second time with `this` as the global Window object, which was causing an error because that has a null `parentNode` attribute. 4. added the `cursor: pointer` style that was needed since the element didn't have an href anymore 5. change the mpv flags `--terminal` -> `--quiet`. This means we get error messages (eg from yt-dlp) in error logs and in the `:process` page now. It can get a bit spammy though if you are running from a terminal. I'm getting a log of keepalive warning and error logs from ffmpeg. On the other hand it's really annoying to see a "process failed, see :process for details" and having no error messages in there. Fixes: #7838
-rw-r--r--doc/changelog.asciidoc10
-rwxr-xr-xmisc/userscripts/view_in_mpv7
2 files changed, 13 insertions, 4 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index f1bd96f81..12416bcc2 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -15,6 +15,16 @@ breaking changes (such as renamed commands) can happen in minor releases.
// `Fixed` for any bug fixes.
// `Security` to invite users to upgrade in case of vulnerabilities.
+[[v3.0.1]]
+v3.0.1 (unreleased)
+-------------------
+
+Fixed
+~~~~~
+
+- The "restore video" functionality of the `view_in_mpv` script works again on
+ webengine.
+
[[v3.0.0]]
v3.0.0 (2023-08-18)
-------------------
diff --git a/misc/userscripts/view_in_mpv b/misc/userscripts/view_in_mpv
index 472920433..4f371c6b5 100755
--- a/misc/userscripts/view_in_mpv
+++ b/misc/userscripts/view_in_mpv
@@ -49,7 +49,7 @@ msg() {
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}
+MPV_FLAGS=${MPV_FLAGS:- --force-window --quiet --keep-open=yes --ytdl}
IFS=" " read -r -a video_command <<< "$MPV_COMMAND $MPV_FLAGS"
js() {
@@ -94,9 +94,9 @@ cat <<EOF
<a style=\\"font-weight: bold;
color: white;
background: transparent;
+ cursor: pointer;
\\"
onClick=\\"restore_video(this, " + i + ");\\"
- href=\\"javascript: restore_video(this, " + i + ")\\"
>click here</a>.
</p>
";
@@ -119,7 +119,6 @@ cat <<EOF
function restore_video(obj, index) {
obj = App.all_replacements[index];
video = App.backup_videos[index];
- console.log(video);
obj.parentNode.replaceChild(video, obj);
}
@@ -137,7 +136,7 @@ EOF
printjs() {
js | sed 's,//.*$,,' | tr '\n' ' '
}
-echo "jseval -q $(printjs)" >> "$QUTE_FIFO"
+echo "jseval -q -w main $(printjs)" >> "$QUTE_FIFO"
msg info "Opening $QUTE_URL with mpv"
"${video_command[@]}" "$@" "$QUTE_URL"