Skip to content

Instantly share code, notes, and snippets.

@OozoraHaruto
Last active October 19, 2021 08:01
Show Gist options
  • Save OozoraHaruto/d59b3e355a1840d719bf4dc315b2e6bd to your computer and use it in GitHub Desktop.
Save OozoraHaruto/d59b3e355a1840d719bf4dc315b2e6bd to your computer and use it in GitHub Desktop.
remove the bars that can be seen on Mirrative's fullscreen
// ==UserScript==
// @name Mirrativ Live Remove Fullscreen bars
// @namespace https://gist.github.com/oozorataiyou/d59b3e355a1840d719bf4dc315b2e6bd
// @version 1.1
// @description remove the bars that can be seen on Mirrative's fullscreen ('f': fullscreen, 'Esc': exit fullscreen)
// @author 大空太陽
// @match https://www.mirrativ.com/*
// @match https://www.mirrativ.com/live/*
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// ==/UserScript==
(function() {
'use strict';
$.noConflict();
let config = {
subtree: true,
childList: true,
attributes: false,
characterData: false,
attributeOldValue: false,
characterDataOldValue: false
}
const nonFullScreenClass = '._33olNWAEgIHL2c8_QMlDNK';
const fullScreenClass = '.eG8jgpgcn2ztUcOrsAD29';
function addObserverIfNonFullScreen() {
var wrapper = document.querySelector(nonFullScreenClass);
if(!wrapper) {
window.setTimeout(addObserverIfNonFullScreen,500);
return;
}
//console.log("Not Full screen");
obsNonFullScreen.observe(wrapper,config);
}
function addObserverIfFullScreen() {
var wrapper = document.querySelector(fullScreenClass);
if(!wrapper) {
window.setTimeout(addObserverIfFullScreen,500);
return;
}
//console.log("Full screen");
obsFullScreen.observe(wrapper,config);
}
function addObserverIfProfileScreen(){
var wrapper = document.querySelector('.mrLiveList__list');
if(!wrapper) {
window.setTimeout(addObserverIfProfileScreen,500);
return;
}
obsProfileScreen.observe(wrapper,config);
}
function addObserverIfWatching(){
var fullScreenWrapper = document.querySelector(fullScreenClass);
var nonFullScreenWrapper = document.querySelector(nonFullScreenClass);
if(!fullScreenWrapper && nonFullScreenWrapper) {
window.setTimeout(addObserverIfProfileScreen,500);
return;
}else if (fullScreenWrapper){
obsPlayButton.observe(fullScreenWrapper,config);
}else if (nonFullScreenWrapper){
obsPlayButton.observe(nonFullScreenWrapper,config);
}
}
const buttonFullScreen = "._3reIGnvaSMqjEs46UkqdKk";
const buttonCloseFullScreen = '._3IsIw7HJYYq2hefSeh3x1G';
const classHeader = '._33s0v6OyWR6mRY4Mj-ns1W';
const classFooter = '._3jDxHPzo86E39GgWmwfXWK';
document.addEventListener('keyup', (e) => {
// console.log(`keyboard code ${e.code}`);
if (e.code === "KeyF"){
jQuery(buttonFullScreen).click();
addObserverIfFullScreen();
} else if (e.code === "Escape"){
jQuery(buttonCloseFullScreen).click();
} else if (e.code === "KeyH"){
console.log("Hide");
if(jQuery(classHeader)){ //Hide header
jQuery(classHeader).hide();
}
if(jQuery(classFooter)){ //Hide footer
jQuery(classFooter).hide();
}
}
});
const obsNonFullScreen = new MutationObserver(function(mutations){
if(jQuery(nonFullScreenClass).length > 0){ // Wrapper
if(jQuery(buttonFullScreen)){ //Autoclick Fullscreen
jQuery(buttonFullScreen).click();
addObserverIfFullScreen();
}
}
addObserverIfWatching();
});
const obsFullScreen = new MutationObserver(function(mutations){
if(jQuery(classHeader)){ //Hide header
jQuery(classHeader).hide();
}
if(jQuery(classFooter)){ //Hide footer
jQuery(classFooter).hide();
}
addObserverIfWatching();
});
const liveLinkClass = 'a._3YLDz8EFiRMs34RwJvY9kE';
const obsProfileScreen = new MutationObserver(function(mutations){
if(jQuery(liveLinkClass).length > 0){
let liveLink = document.querySelector(liveLinkClass);
if(liveLink){
// console.log("Found Link");
liveLink.addEventListener("click", addObserverIfNonFullScreen());
liveLink.click();
} else {
//console.log("No Link");
}
}
});
const buttonPlayFullScreenVer = '._1EHremrYhGUqkaV7HE72vs'
const buttonPlayNonFullScreenVer = '._3TGNrjmyR8FGTVn0OqHcXu'
const obsPlayButton = new MutationObserver(function(mutations){
if(jQuery(buttonPlayFullScreenVer)){
if (jQuery(buttonPlayFullScreenVer).css("display") === "block") {
jQuery(buttonPlayFullScreenVer).click()
}
}
if(jQuery(buttonPlayNonFullScreenVer)){
if (jQuery(buttonPlayNonFullScreenVer).css("display") === "block") {
jQuery(buttonPlayNonFullScreenVer).click()
}
}
});
jQuery(document).ready(function() {
addObserverIfNonFullScreen();
addObserverIfProfileScreen();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment