tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

picture_in_picture_overrides.js (13952B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 /* globals browser */
      8 
      9 let AVAILABLE_PIP_OVERRIDES;
     10 
     11 {
     12  // See PictureInPictureControls.sys.mjs for these values.
     13  // eslint-disable-next-line no-unused-vars
     14  const TOGGLE_POLICIES = browser.pictureInPictureChild.getPolicies();
     15  const KEYBOARD_CONTROLS = browser.pictureInPictureChild.getKeyboardControls();
     16 
     17  AVAILABLE_PIP_OVERRIDES = {
     18    // The keys of this object are match patterns for URLs, as documented in
     19    // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns
     20    //
     21    // Example:
     22    //  const KEYBOARD_CONTROLS = browser.pictureInPictureChild.getKeyboardControls();
     23    //
     24    //
     25    // "https://*.youtube.com/*": {
     26    //   policy: TOGGLE_POLICIES.THREE_QUARTERS,
     27    //   disabledKeyboardControls: KEYBOARD_CONTROLS.PLAY_PAUSE | KEYBOARD_CONTROLS.VOLUME,
     28    // },
     29    // "https://*.twitch.tv/mikeconley_dot_ca/*": {
     30    //   policy: TOGGLE_POLICIES.TOP,
     31    //   disabledKeyboardControls: KEYBOARD_CONTROLS.ALL,
     32    // },
     33 
     34    tests: {
     35      // FOR TESTS ONLY!
     36      "https://mochitest.youtube.com/*browser/browser/extensions/pictureinpicture/tests/browser/test-mock-wrapper.html":
     37        {
     38          videoWrapperScriptPath: "video-wrappers/mock-wrapper.js",
     39        },
     40      "https://mochitest.youtube.com/*browser/browser/extensions/pictureinpicture/tests/browser/test-toggle-visibility.html":
     41        {
     42          videoWrapperScriptPath: "video-wrappers/mock-wrapper.js",
     43        },
     44    },
     45 
     46    abcnews: {
     47      "https://*.abcnews.go.com/*": {
     48        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
     49      },
     50    },
     51 
     52    airmozilla: {
     53      "https://*.mozilla.hosted.panopto.com/*": {
     54        videoWrapperScriptPath: "video-wrappers/airmozilla.js",
     55      },
     56    },
     57 
     58    aol: {
     59      "https://*.aol.com/*": {
     60        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
     61      },
     62    },
     63 
     64    apple: {
     65      "https://www.apple.com/*": {
     66        videoWrapperScriptPath: "video-wrappers/apple.js",
     67      },
     68    },
     69 
     70    arte: {
     71      "https://*.arte.tv/*": {
     72        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
     73      },
     74    },
     75 
     76    bbc: {
     77      "https://*.bbc.com/*": {
     78        videoWrapperScriptPath: "video-wrappers/bbc.js",
     79      },
     80      "https://*.bbc.co.uk/*": {
     81        videoWrapperScriptPath: "video-wrappers/bbc.js",
     82      },
     83    },
     84 
     85    brightcove: {
     86      "https://*.brightcove.com/*": {
     87        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
     88      },
     89    },
     90 
     91    canalplus: {
     92      "https://*.canalplus.com/live/*": {
     93        videoWrapperScriptPath: "video-wrappers/canalplus.js",
     94        disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK,
     95      },
     96      "https://*.canalplus.com/*": {
     97        videoWrapperScriptPath: "video-wrappers/canalplus.js",
     98      },
     99    },
    100 
    101    cbc: {
    102      "https://*.cbc.ca/*": {
    103        videoWrapperScriptPath: "video-wrappers/cbc.js",
    104      },
    105    },
    106 
    107    cnbc: {
    108      "https://*.cnbc.com/*": {
    109        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    110      },
    111    },
    112 
    113    cpac: {
    114      "https://*.cpac.ca/*": {
    115        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    116      },
    117    },
    118 
    119    cspan: {
    120      "https://*.c-span.org/*": {
    121        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    122      },
    123    },
    124 
    125    dailymotion: {
    126      "https://*.dailymotion.com/*": {
    127        videoWrapperScriptPath: "video-wrappers/dailymotion.js",
    128      },
    129    },
    130 
    131    disneyplus: {
    132      "https://*.disneyplus.com/*": {
    133        videoWrapperScriptPath: "video-wrappers/disneyplus.js",
    134      },
    135    },
    136 
    137    edx: {
    138      "https://*.edx.org/*": {
    139        videoWrapperScriptPath: "video-wrappers/edx.js",
    140      },
    141    },
    142 
    143    fandom: {
    144      "https://*.fandom.com/*": {
    145        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    146      },
    147    },
    148 
    149    fastcompany: {
    150      "https://*.fastcompany.com/*": {
    151        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    152      },
    153    },
    154 
    155    frontendMasters: {
    156      "https://*.frontendmasters.com/*": {
    157        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    158      },
    159    },
    160 
    161    funimation: {
    162      "https://*.funimation.com/*": {
    163        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    164      },
    165    },
    166 
    167    fuse: {
    168      "https://*.fuse.tv/*": {
    169        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    170      },
    171    },
    172 
    173    hbomax: {
    174      "https://play.hbomax.com/page/*": { policy: TOGGLE_POLICIES.HIDDEN },
    175      "https://play.hbomax.com/player/*": {
    176        videoWrapperScriptPath: "video-wrappers/hbomax.js",
    177      },
    178    },
    179 
    180    hotstar: {
    181      "https://*.hotstar.com/*": {
    182        videoWrapperScriptPath: "video-wrappers/hotstar.js",
    183      },
    184    },
    185 
    186    hulu: {
    187      "https://www.hulu.com/watch/*": {
    188        policy: TOGGLE_POLICIES.ONE_QUARTER,
    189        videoWrapperScriptPath: "video-wrappers/hulu.js",
    190      },
    191    },
    192 
    193    imdb: {
    194      "https://*.imdb.com/*": {
    195        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    196      },
    197    },
    198 
    199    indpendentuk: {
    200      "https://*.independent.co.uk/*": {
    201        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    202      },
    203    },
    204 
    205    indy100: {
    206      "https://*.indy100.com/*": {
    207        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    208      },
    209    },
    210 
    211    instagram: {
    212      "https://www.instagram.com/*": { policy: TOGGLE_POLICIES.ONE_QUARTER },
    213    },
    214 
    215    internetArchive: {
    216      "https://*.archive.org/*": {
    217        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    218      },
    219    },
    220 
    221    iq: {
    222      "https://*.iq.com/play/*": {
    223        videoWrapperScriptPath: "video-wrappers/iq.js",
    224      },
    225    },
    226 
    227    kick: {
    228      "https://*.kick.com/*": {
    229        visibilityThreshold: 0.7,
    230        videoWrapperScriptPath: "video-wrappers/kick.js",
    231      },
    232    },
    233 
    234    joyn: {
    235      "https://www.joyn.de/play/*": {
    236        videoWrapperScriptPath: "video-wrappers/joyn.js",
    237      },
    238      "https://www.joyn.at/play/*": {
    239        videoWrapperScriptPath: "video-wrappers/joyn.js",
    240      },
    241      "https://www.joyn.ch/play/*": {
    242        videoWrapperScriptPath: "video-wrappers/joyn.js",
    243      },
    244    },
    245 
    246    laracasts: {
    247      "https://*.laracasts.com/*": { policy: TOGGLE_POLICIES.ONE_QUARTER },
    248    },
    249 
    250    msn: {
    251      "https://*.msn.com/*": {
    252        visibilityThreshold: 0.7,
    253      },
    254    },
    255 
    256    msnbc: {
    257      "https://*.msnbc.com/*": {
    258        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    259      },
    260    },
    261 
    262    mxplayer: {
    263      "https://*.mxplayer.in/*": {
    264        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    265      },
    266    },
    267 
    268    nbcnews: {
    269      "https://*.nbcnews.com/*": {
    270        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    271      },
    272    },
    273 
    274    nbcUniversal: {
    275      "https://*.nbcuni.com/*": {
    276        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    277      },
    278    },
    279 
    280    nebula: {
    281      "https://*.nebula.app/*": {
    282        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    283      },
    284    },
    285 
    286    netflix: {
    287      "https://*.netflix.com/*": {
    288        videoWrapperScriptPath: "video-wrappers/netflix.js",
    289      },
    290      "https://*.netflix.com/browse*": { policy: TOGGLE_POLICIES.HIDDEN },
    291      "https://*.netflix.com/latest*": { policy: TOGGLE_POLICIES.HIDDEN },
    292      "https://*.netflix.com/Kids*": { policy: TOGGLE_POLICIES.HIDDEN },
    293      "https://*.netflix.com/title*": { policy: TOGGLE_POLICIES.HIDDEN },
    294      "https://*.netflix.com/notification*": { policy: TOGGLE_POLICIES.HIDDEN },
    295      "https://*.netflix.com/search*": { policy: TOGGLE_POLICIES.HIDDEN },
    296    },
    297 
    298    nowtv: {
    299      "https://*.nowtv.it/*": {
    300        videoWrapperScriptPath: "video-wrappers/peacocktv.js",
    301      },
    302      "https://*.nowtv.com/*": {
    303        videoWrapperScriptPath: "video-wrappers/peacocktv.js",
    304      },
    305      "https://*.nowtv.de/*": {
    306        videoWrapperScriptPath: "video-wrappers/peacocktv.js",
    307      },
    308    },
    309 
    310    nytimes: {
    311      "https://*.nytimes.com/*": {
    312        videoWrapperScriptPath: "video-wrappers/nytimes.js",
    313      },
    314    },
    315 
    316    peacock: {
    317      "https://*.peacocktv.com/*": {
    318        videoWrapperScriptPath: "video-wrappers/peacocktv.js",
    319      },
    320    },
    321 
    322    pbs: {
    323      "https://*.pbs.org/*": {
    324        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    325      },
    326      "https://*.pbskids.org/*": {
    327        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    328      },
    329    },
    330 
    331    piped: {
    332      "https://*.piped.kavin.rocks/*": {
    333        videoWrapperScriptPath: "video-wrappers/piped.js",
    334      },
    335      "https://*.piped.silkky.cloud/*": {
    336        videoWrapperScriptPath: "video-wrappers/piped.js",
    337      },
    338    },
    339 
    340    primeVideo: {
    341      "https://*.primevideo.com/*": {
    342        visibilityThreshold: 0.9,
    343        videoWrapperScriptPath: "video-wrappers/primeVideo.js",
    344      },
    345      "https://*.amazon.com/*": {
    346        visibilityThreshold: 0.9,
    347        videoWrapperScriptPath: "video-wrappers/primeVideo.js",
    348      },
    349    },
    350 
    351    radiocanada: {
    352      "https://*.ici.radio-canada.ca/*": {
    353        videoWrapperScriptPath: "video-wrappers/radiocanada.js",
    354      },
    355    },
    356 
    357    reddit: {
    358      "https://*.reddit.com/*": { policy: TOGGLE_POLICIES.ONE_QUARTER },
    359    },
    360 
    361    reuters: {
    362      "https://*.reuters.com/*": {
    363        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    364      },
    365    },
    366 
    367    rte: {
    368      "https://www.rte.ie/player/*": {
    369        videoWrapperScriptPath: "video-wrappers/hotstar.js",
    370      },
    371    },
    372 
    373    showmax: {
    374      "https://*.showmax.com/*": {
    375        videoWrapperScriptPath: "video-wrappers/peacocktv.js",
    376      },
    377    },
    378 
    379    skyshowtime: {
    380      "https://*.skyshowtime.com/*": {
    381        videoWrapperScriptPath: "video-wrappers/peacocktv.js",
    382      },
    383    },
    384 
    385    sonyliv: {
    386      "https://*.sonyliv.com/*": {
    387        videoWrapperScriptPath: "video-wrappers/sonyliv.js",
    388      },
    389    },
    390 
    391    syfy: {
    392      "https://*.syfy.com/*": {
    393        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    394      },
    395    },
    396 
    397    ted: {
    398      "https://*.ted.com/*": {
    399        showHiddenTextTracks: true,
    400      },
    401    },
    402 
    403    time: {
    404      "https://*.time.com/*": {
    405        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    406      },
    407    },
    408 
    409    timvision: {
    410      "https://*.timvision.it/TV/*": {
    411        videoWrapperScriptPath: "video-wrappers/canalplus.js",
    412        disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK,
    413      },
    414      "https://*.timvision.it/*": {
    415        videoWrapperScriptPath: "video-wrappers/canalplus.js",
    416      },
    417    },
    418 
    419    tubi: {
    420      "https://*.tubitv.com/live*": {
    421        videoWrapperScriptPath: "video-wrappers/tubilive.js",
    422      },
    423      "https://*.tubitv.com/movies*": {
    424        videoWrapperScriptPath: "video-wrappers/tubi.js",
    425      },
    426      "https://*.tubitv.com/tv-shows*": {
    427        videoWrapperScriptPath: "video-wrappers/tubi.js",
    428      },
    429    },
    430 
    431    twitch: {
    432      "https://*.twitch.tv/*": {
    433        videoWrapperScriptPath: "video-wrappers/twitch.js",
    434        policy: TOGGLE_POLICIES.ONE_QUARTER,
    435        disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK,
    436      },
    437      "https://*.twitch.tech/*": {
    438        videoWrapperScriptPath: "video-wrappers/twitch.js",
    439        policy: TOGGLE_POLICIES.ONE_QUARTER,
    440        disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK,
    441      },
    442      "https://*.twitch.a2z.com/*": {
    443        videoWrapperScriptPath: "video-wrappers/twitch.js",
    444        policy: TOGGLE_POLICIES.ONE_QUARTER,
    445        disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK,
    446      },
    447    },
    448 
    449    udemy: {
    450      "https://*.udemy.com/*": {
    451        videoWrapperScriptPath: "video-wrappers/udemy.js",
    452        policy: TOGGLE_POLICIES.ONE_QUARTER,
    453      },
    454    },
    455 
    456    univision: {
    457      "https://*.univision.com/*": {
    458        videoWrapperScriptPath: "video-wrappers/jwplayerWrapper.js",
    459      },
    460    },
    461 
    462    viki: {
    463      "https://*.viki.com/*": {
    464        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    465      },
    466    },
    467 
    468    vimeo: {
    469      "https://*.vimeo.com/*": {
    470        showHiddenTextTracks: true,
    471      },
    472      "https://embed.vhx.tv/*": {
    473        showHiddenTextTracks: true,
    474      },
    475      "https://embed.criterionchannel.com/*": {
    476        showHiddenTextTracks: true,
    477      },
    478    },
    479 
    480    voot: {
    481      "https://*.voot.com/*": {
    482        videoWrapperScriptPath: "video-wrappers/voot.js",
    483      },
    484    },
    485 
    486    wired: {
    487      "https://*.wired.com/*": {
    488        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    489      },
    490    },
    491 
    492    yahoo: {
    493      "https://*.s.yimg.com/*": {
    494        videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
    495      },
    496    },
    497 
    498    youtube: {
    499      /**
    500       * The threshold of 0.6 is so that users can click on the "Skip Ads"
    501       * button on the YouTube site player without accidentally triggering
    502       * PiP, and so that the video player's semi-transparent gear menu can be
    503       * used without accidentally triggering PiP.
    504       */
    505      "https://*.youtube.com/*": {
    506        visibilityThreshold: 0.6,
    507        videoWrapperScriptPath: "video-wrappers/youtube.js",
    508      },
    509      "https://*.youtube-nocookie.com/*": {
    510        visibilityThreshold: 0.9,
    511        videoWrapperScriptPath: "video-wrappers/youtube.js",
    512      },
    513    },
    514 
    515    washingtonpost: {
    516      "https://*.washingtonpost.com/*": {
    517        videoWrapperScriptPath: "video-wrappers/washingtonpost.js",
    518      },
    519    },
    520 
    521    zdf: {
    522      "https://*.zdf.de/*": {
    523        videoWrapperScriptPath: "video-wrappers/zdf.js",
    524      },
    525      "https://*.3sat.de/*": {
    526        videoWrapperScriptPath: "video-wrappers/zdf.js",
    527      },
    528      "https://*.phoenix.de/*": {
    529        videoWrapperScriptPath: "video-wrappers/zdf.js",
    530      },
    531    },
    532  };
    533 }