Skip to content

Instantly share code, notes, and snippets.

@kaiserdj
Last active December 20, 2018 18:38
Show Gist options
  • Save kaiserdj/4a169fdef25615daa75a222b416c3752 to your computer and use it in GitHub Desktop.
Save kaiserdj/4a169fdef25615daa75a222b416c3752 to your computer and use it in GitHub Desktop.
Barra abajo socialanime
// ==UserScript==
// @name Barra abajo socialanime
// @namespace http://tampermonkey.net/
// @version 0.4
// @description La barra principal de SocialAnime se pone abajo
// @author Kaiserdj
// @match https://socialani.me/*
// @grant none
// @require http://code.jquery.com/jquery-3.3.1.js
// @updateURL https://gist.github.com/kaiserdj/4a169fdef25615daa75a222b416c3752/raw/bcfba67735e1a0f635a1a7ffa77c624c0c841975/Barra_abajo_socialanime.user.js
// @downloadURL https://gist.github.com/kaiserdj/4a169fdef25615daa75a222b416c3752/raw/bcfba67735e1a0f635a1a7ffa77c624c0c841975/Barra_abajo_socialanime.user.js
// ==/UserScript==
(function() {
'use strict';
if(window.attachEvent) {
window.attachEvent('onload', inject);
} else {
if(window.onload) {
var curronload = window.onload;
var newonload = function(evt) {
curronload(evt);
inject();
};
window.onload = newonload;
} else {
window.onload = inject;
}
}
$("body").click(function() {
if($('#fullscreen').length > 0){
} else {
inject()
}
});
$("document").ready( function() {
if($('#fullscreen').length > 0){
} else {
inject()
}
});
$(window).on('load', function(){
if($('.sa-header__btns').length > 0){
var checkExist = setInterval(function() {
if ($('.sa-header__btns').length) {
clearInterval(checkExist);
if($('#fullscreen').length > 0){
} else {
inject()
}
}
}, 100);
if($('#fullscreen').length > 0){
} else {
inject()
}
} else {
if($('#fullscreen').length > 0){
} else {
inject()
}
}
});
$("body").click(function() {
$(window).on('load', function(){
if($('.sa-header__btns').length > 0){
} else {
if($('#fullscreen').length > 0){
} else {
inject()
}
}
});
});
function inject() {
$(".sa-header__btns").prepend (`<button id="back_button" class="sa-header__btns-item md-icon-button md-button md-ink-ripple back_button" type="button"><i class="material-icons ng-scope">full screen</i><div class="md-ripple-container"></div></button><button id="fullscreen" class="sa-header__btns-item md-icon-button md-button md-ink-ripple fullscreen" type="button"><i class="material-icons ng-scope">full screen</i><div class="md-ripple-container"></div></button>` );
document.getElementById('fullscreen').onclick = function(){
toggleFullScreen();
}
if((window.fullScreen) || (window.innerWidth == screen.width && window.innerHeight == screen.height)) {
$('.fullscreen').addClass( "quitar_fullscreen" );
}
}
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('.sa-page {margin-top: 0px;}');
addGlobalStyle('.sa-header {top: initial; bottom: 0;}');
addGlobalStyle('.t-margin-bottom-md {margin-bottom: 75px!important;}');
addGlobalStyle('.sa-main-dashboard__container { margin-bottom: 75px;}');
addGlobalStyle('.sa-notice-dashboard {margin-bottom: 75px;}');
addGlobalStyle('.sa-main-dashboard__wrapper {margin-bottom: 75px;}');
addGlobalStyle('.sa-series-dashboard {margin-bottom: 75px;}');
addGlobalStyle('.fullscreen {background-repeat: no-repeat !important; background-position-x: center !important; background-position-y: center !important; background: url(https://i.imgur.com/iLhQhZS.png);}');
addGlobalStyle('.back_button {background-repeat: no-repeat !important; background-position-x: center !important; background-position-y: center !important; background: url(https://i.imgur.com/925dnWX.png);}');
addGlobalStyle('.quitar_fullscreen {background: url(https://i.imgur.com/LmmsHZv.png) !important; background-repeat: no-repeat !important; background-position-x: center !important; background-position-y: center !important;}');
function toggleFullScreen() {
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.msRequestFullscreen) {
document.documentElement.msRequestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}
$(document).on('click', '.back_button', function() {
window.history.back();
});
$(document).on('click', '.fullscreen', function() {
$( this ).addClass( "quitar_fullscreen" );
});
$(document).on('click', '.quitar_fullscreen', function() {
$( this ).removeClass( "quitar_fullscreen" );
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment