Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
chrome.runtime.onMessage.addListener(gotMessage)
function gotMessage(message, sender, sendResponse){
let direction = 0;
if(message.direction == 'up'){
direction = -500;
} else if(message.direction == 'down'){
direction = +500;
} else if (message.direction == 'turn off') {
const mask = document.getElementById('body-maskDiv');
if (mask) {
removeMask();
} else {
addMask();
}
}
window.scrollBy({
top: direction,
left: 0,
behavior: 'smooth'
});
}
function addMask() {
var maskDiv = document.createElement("div");
maskDiv.id = 'body-maskDiv';
maskDiv.setAttribute('style', 'background:rgba(0,0,0,0.6);position:fixed;top:0;width:100%;height:100%;z-index:999');
var playerContainer = document.getElementById('player-container');
playerContainer && (playerContainer.style.zIndex = '1001');
document.body.appendChild(maskDiv);
}
function removeMask() {
document.getElementById('body-maskDiv').remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.