Skip to content

Instantly share code, notes, and snippets.

@avin
Created December 30, 2022 13:33
Show Gist options
  • Save avin/3a92017305f1f379892ba57517a57d70 to your computer and use it in GitHub Desktop.
Save avin/3a92017305f1f379892ba57517a57d70 to your computer and use it in GitHub Desktop.
Coursehunter Separate Video Player
// ==UserScript==
// @name Coursehunter Separate Video Player
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://coursehunter.net/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
const onPageReady = (fn) => {
if (document.readyState !== 'loading') {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
};
onPageReady(() => {
const doClean = (el) => {
const parent = el.parentElement;
for (const child of Array.from(parent.childNodes)) {
if (child !== el) {
// child.remove();
try {
child.style.display = 'none';
} catch {}
}
}
el.style.padding = 0;
el.style.margin = 0;
if (parent !== document.body) {
doClean(parent);
}
};
function popupWindow(url, title, w, h) {
const left = screen.width / 2 - w / 2;
const top = screen.height / 2 - h / 2;
return window.open(
url,
title,
`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${w}, height=${h}, top=${top}, left=${left}`
);
}
const button = document.createElement("button");
button.id = 'open-sep-win';
button.innerHTML = 'OPEN SEP PLAYER';
button.style.cssText = 'font-size: .75rem; cursor: pointer;background-color: #000; color: #999;';
document.querySelector('.player').prepend(button);
document.querySelector('#open-sep-win').addEventListener('click', () => {
popupWindow(location.href, 'SoloPlayer', 800, 600);
});
if (window.top.name === 'SoloPlayer') {
const playerEl = document.querySelector('#player');
doClean(playerEl);
playerEl.style.width = '100vw';
playerEl.style.height = '100vh';
document.body.parentElement.style.overflow = 'hidden';
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment