Just Do It UserScript
code:script.js
function removeVideo() {
document.querySelector('.shia-do-it')?.remove?.();
}
function addVideo() {
removeVideo();
const shiaDoIt = document.createElement('div');
shiaDoIt.classList.add('shia-do-it');
shiaDoIt.attachShadow({mode: 'open'});
const container = document.createElement('div');
container.classList.add('container');
const video = document.createElement('video');
video.width = 960;
video.height = 540;
video.name = 'media';
container.append(video);
const style = document.createElement('style');
style.textContent = `
:host {
position: fixed;
bottom: 0;
z-index: 99999;
right: 0;
pointer-events: none;
}
.container {
width: 720px;
overflow: hidden;
display: block;
height: 535px;
}
.container video {
margin-top: -5px;
max-width: none;
padding: 0;
visibility: hidden;
}
`;
shiaDoIt.shadowRoot.append(style);
shiaDoIt.shadowRoot.append(container);
document.body.append(shiaDoIt);
video.src = choice([
]);
video.onended = function () {
removeVideo();
};
video.addEventListener('loadeddata', function () {
video.style.visibility = 'visible';
video.play();
}, false);
video.onerror = function () {
alert('ooops... Shia had a problem. try on another tab');
removeVideo();
};
video.load();
}
scrapbox.PageMenu.addMenu({
title: 'Just Do It',
onClick: () => addVideo(),
});