@@ -14,7 +14,9 @@ const settings = {
14
14
locallyInstalledVersion : null
15
15
} ;
16
16
17
- const MPVSchemePrefix = "mpv://watch#" ;
17
+ function createMpvSchemeURI ( url ) {
18
+ return `mpv://watch#${ url . replace ( / ' / g, "%27" ) } ` ;
19
+ }
18
20
19
21
function contextMenuPatch ( tree , context ) {
20
22
const href = context . target . href || context . target . parentNode . href
@@ -28,14 +30,14 @@ function contextMenuPatch(tree, context) {
28
30
console . log ( "open-in-mpv: link is " + href ) ;
29
31
30
32
if ( settings . locallyInstalledVersion && settings . locallyInstalledVersion >= desktopFileVersion ) {
31
- const newWindow = window . open ( MPVSchemePrefix + href , "_blank" , "noopener noreferrer" ) ;
33
+ const newWindow = window . open ( createMpvSchemeURI ( href ) , "_blank" , "noopener noreferrer" ) ;
32
34
33
35
if ( newWindow === null ) { // is null because opens in external application
34
36
BdApi . UI . showToast ( "" + href + " opened in mpv." , { type : "success" } ) ;
35
37
console . log ( "open-in-mpv: success" ) ;
36
38
} else {
37
39
BdApi . UI . showToast ( "" + href + " failed to open in mpv." , { type : "error" } ) ;
38
- console . log ( `open-in-mpv: failed to open ${ MPVSchemePrefix } ${ href } in mpv.` ) ;
40
+ console . log ( `open-in-mpv: failed to open ${ createMpvSchemeURI ( href ) } in mpv.` ) ;
39
41
}
40
42
} else {
41
43
BdApi . UI . showConfirmationModal ( "Open in mpv" ,
0 commit comments