Just Do It UserScript
original src
使う
jsimport '/api/code/villagepump/Just_Do_It_UserScript/script.js';
背景を透過して出てくるのか
www
数分間書き込みしていないと自動で励ましてくれるようにすると面白そうだけどうざそう
プレゼンモードでも動く
授業で使ってやろうか!
使ってみた
ウケなかった
w
2021-07-02
11:38:25 UserCSSの設定を不要にした
screenshots
script.jsfunction 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);
var choice = (arr) => arr[Math.floor(Math.random() * arr.length)];
video.src = choice([
"https://scrapbox.io/files/60e5b69d017b300023e20ab0.webm",
"https://scrapbox.io/files/60e5b6aee7fe36001c29d1b0.webm",
"https://scrapbox.io/files/60e5b6c3c4127f001e79b713.webm",
"https://scrapbox.io/files/60e5b6e52991f5001e078e7c.webm",
"https://scrapbox.io/files/60e5b6fc01728f001c58d698.webm",
"https://scrapbox.io/files/60e5b7182991f5001e078e85.webm",
]);
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',
image: 'https://i.gyazo.com/945c95593b2328c41d5b36b54d0c2174.png',
onClick: () => addVideo(),
});
Chrome Betaだといちいち字幕出るの草]