everyone. Basically, this streaming website displays 4:3 videos in 16:9, ignoring the aspect ratio and making them all stretched. I checked and the videos were pre-streched, since their resolution is 1024x576.
Nevertheless, I found a way to make them 4:3, which is adding transform: scaleX(0.75)
to the class playkit-container
.
To make things more easier, I'm trying to make a simple Chrome extension with a popup that has a checkbox. If the checkbox is checked, the javascript should add transform: scaleX(0.75)
to playkit-container
. If is not checked, it should, either reset the CSS or set it to transform: scaleX(1.0)
.
Here's what I have:
extension.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Opto AR Fixer</h1>
<p>Fixes the AR of 4:3 episodes streaming on Opto.</p>
<input type="checkbox" name="forcear" id="forcear">
<label for="forcear">Force 4:3</label>
<script src="extension.js"></script>
</body>
</html>
extension.js
var popup = chrome.extension.getViews({type:"popup"})[0];
var checkBox = popup.document.getElementById("forcear").addEventListener("click", myFunction);
function myFunction() {
if (checkBox.checked == true){
document.getElementsByClassName("playkit-container")[0].style.transform = "scaleX(0.75)"
} else {
document.getElementsByClassName("playkit-container")[0].style.transform = "scaleX(1.0)"
}
}
However, nothing happens. If I inspect the popup and check the logs, whenever I click the button it throws me these errors:
Uncaught TypeError: Cannot read property 'checked' of undefined
Uncaught TypeError: chrome.extension.getViews is not a function
What am I missing here?