andy-portmen / external-application-button

Communicate with external applications of your OS through a toolbar button or context menu item.
https://webextension.org/listing/external-application-button.html
168 stars 56 forks source link

document.currentScript.output returns "undefined" on Facebook and Reddit #107

Closed raziel6868 closed 12 hours ago

raziel6868 commented 1 week ago

First of all, I must thank you for creating such a powerful extension ☺️

The document.currentScript.output is correctly passed string to [PRE_SCRIPT] on YouTube. However, when I try on other platforms such as Facebook and Reddit, it returns "undefined" to [PRE_SCRIPT].

I'm using Firefox ESR115 and here's my config:

{
  "apps": {
    "0.7210677491887629": {
      "name": "Download as MP4",
      "path": "wt",
      "args": "\"C:\\Program Files\\Shutter Encoder\\Library\\yt-dlp.exe\" -S res:1080,fps,vcodec:h264,acodec:aac --no-mtime --cookies-from-browser firefox -o [PRE_SCRIPT] [HREF]",
      "pre": "var href = window.location.href;\nvar outputPath = \"%userprofile%\\\\Desktop\";\ndocument.currentScript.output = href.includes(\"youtube.com/playlist?list=\") ? outputPath + \"\\\\%(playlist_title)s\\\\%(title)s.%(ext)s --yes-playlist --fragment-retries 200 -R 200 -N 6 --retry-sleep http,fragment,file_access:linear=0.5:10:0.2\" : (href.includes(\"youtube.com/watch?v=\") && href.includes(\"&list=\")) ? (confirm(\"Do you want to download the whole playlist?\") ? outputPath + \"\\\\%(playlist_title)s\\\\%(title)s.%(ext)s --yes-playlist --fragment-retries 200 -R 200 -N 6 --retry-sleep http,fragment,file_access:linear=0.5:10:0.2\" : outputPath + \"\\\\%(title)s.%(ext)s --no-playlist\") : outputPath + \"\\\\%(title)s.%(ext)s --no-playlist\";",
      "post": "",
      "toolbar": true,
      "context": [
        "page",
        "link",
        "video"
      ]
    }
  }
}

The results: In Youtube: wt.exe "C:\Program Files\Shutter Encoder\Library\yt-dlp.exe" -S res:1080,fps,vcodec:h264,acodec:aac --no-mtime --cookies-from-browser firefox -o %userprofile%\Desktop\%(title)s.%(ext)s --no-playlist https://www.youtube.com/watch?v=dQw4w9WgXcQ

In Facebook: wt.exe "C:\Program Files\Shutter Encoder\Library\yt-dlp.exe" -S res:1080,fps,vcodec:h264,acodec:aac --no-mtime --cookies-from-browser firefox -o undefined https://www.facebook.com/watch/?v=2706186239674291

In Reddit: wt.exe "C:\Program Files\Shutter Encoder\Library\yt-dlp.exe" -S res:1080,fps,vcodec:h264,acodec:aac --no-mtime --cookies-from-browser firefox -o undefined https://www.reddit.com/r/Bossfight/comments/1dkl665/the_brander_being_of_steel_and_flame

andy-portmen commented 1 week ago

Consider checking the page's DevTools. The websites might have Content Security Policy (CSP) limitations that restrict script execution. If that's the case, you could try using a CSP unblocker extension or explore different approaches to extract parameters from the pages.

raziel6868 commented 12 hours ago

OK, thank you so much for your help