Question trying to make a userscript to activate PIP [userscript creation help]

Daehock

Junior Member
Sep 22, 2021
3
0
6
hi, i have a question, i have BASIC code knowledge, not much more, and what i do know is pre 2010 mostly. PHP CSS MYSQL HTML and the like, ive been getting into making userscripts in my spare time over the past few years, and recently, fell in love with the picture in picture (or PIP) feature that firefox introduced in their quantum update a WHILE ago, i use multiple monitors, and almost always browse things on one, but have the video on the other, and pip lests you do that, without having multipe windows open and spread out across your monitors, (fullscreen only works on the screen the content is on, but pip will work on any screen) i want to edit an old userscript i made a while ago to work with PIP mode instead of norrnal fullscreen, but i am at a loss, ive been studying this , and this, and this, to try and learn what to do....but that whitepaper is pretty dense...i just cant figure it out, my brain is fried, ive already deleted my code multiple times from sheer frustration, and im starting to think that it just might not be able to be done, if anyone could help me that would be AMAZING

this is pretty much what i had done, like i said i just edited my old code and tried to make it work, my knowledge is rather limited, so i try to keep it as simple as i possibly can, for my own sanity if nothing else.
Code:
// ==UserScript==
// @name         anime couch mode activator-pard deux-fullscreen
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Adds extra keyboard shortcuts to html5 videos and automatically enters fullscreen.
// @author       Daehock
// @Thanks       Skillrax  & v4lt5u

removed includes, because its just a list of "grey" legality streaming sites

// @grant        none
// ==/UserScript==


var elem = document.getElementsByTagName("video")[0];
if (elem.requestPictureInPicture) {
  elem.requestPictureInPicture();
}

document.getElementsByTagName("video")[0].setAttribute("controls","controls");

document.getElementsByTagName("video")[0].click(("video")[0]);

now this, is the code i wanted to make work with PIP, now it finds the first video on a given page, and selects it, so that keyboard shortcuts can work on it, and then make it go fullscreen, so what i edited it to do is find the first video on the page, make it active, and then enable PIP on that video, no matter what i do i cant make it activate PIP, im starting to think that a userscript cant do it for some reason....who knows, maybe its only a firefox problem...or maybe im forgetting something really important, i honestly have no idea, my brain is officially fried, its likely something so simple its not even funny, but i have no idea.....