feat(awsacademy.instructure): added userscript for awsacademy

This commit is contained in:
Tigor Hutasuhut 2022-10-11 21:15:24 +07:00
parent 67b70aed7e
commit bfd35edec8
1 changed files with 40 additions and 0 deletions

40
awsacademy.instructure.js Normal file
View File

@ -0,0 +1,40 @@
// ==UserScript==
// @name AWS Academy - Video Fix
// @namespace awsacademy.instructure.com
// @match https://awsacademy.instructure.com/courses/25280/modules/items/*
// @grant none
// @version 1.0
// @author tigor.hutasuhut@gmail.com
// @require https://cdn.jsdelivr.net/npm/@violentmonkey/dom@2
// @description Fix video sizing for firefox
// ==/UserScript==
const getBestWidth = () => {
switch (true) {
case window.innerWidth <= 1280:
return "50vw";
case window.innerWidth <= 1920:
return "65vw";
default:
return "70vw";
}
};
window.addEventListener("resize", () => {
const content = document.querySelector("div#content.ic-Layout-contentMain");
if (content) {
content.style.setProperty("width", getBestWidth());
}
});
VM.observe(document.body, () => {
const content = document.querySelector("div#content.ic-Layout-contentMain");
if (content) {
content.style.setProperty("width", getBestWidth());
const parent = content.parentElement;
parent.style.setProperty("display", "flex");
parent.style.setProperty("justify-content", "center");
return true;
}
return false;
});