kaiserdj / SocialAnime tools

// ==UserScript==
// @icon https://i.imgur.com/dld3nk4.png
// @name         SocialAnime tools
// @version      0.0.6
// @description  Utilidades para SocialAnime
// @author       Kaiserdj
// @namespace    http://Kaiserdj.tk/
// @homepageURL http://kaiserdj.tk/
// @supportURL http://socialani.me/users/kaiserdj/activity
// @copyright 2018, kaiserdj (https://openuserjs.org/users/kaiserdj)
// @license MIT
// @match        https://socialani.me
// @match        https://socialani.me/home
// @match        https://socialani.me/*
// @match        https://socialani.me*
// @match        http://socialani.me
// @match        http://socialani.me/home
// @match        http://socialani.me/*
// @match        http://socialani.me*
// @grant       GM.setValue
// @grant       GM.getValue
// @require      https://code.jquery.com/jquery-3.2.1.min.js
// @require      https://code.jquery.com/ui/1.12.1/jquery-ui.js
// @updateURL https://openuserjs.org/meta/kaiserdj/SocialAnime_tools.meta.js
// @run-at       document-end
// ==/UserScript==

// ==OpenUserJS==
// @author kaiserdj
// ==/OpenUserJS==

(function () {
    'use strict';
  ///////////////////////////////////////////////////////////////////////////

  /*
  Carga el estilo de JqueryUi
  */

  ///////////////////////////////////////////////////////////////////////////

    $('head').append('<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.12.1/themes/ui-darkness/jquery-ui.css">');
    $('head').append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">');

  ///////////////////////////////////////////////////////////////////////////

  /*
  Tools para hacer una espera antes de ejecutar algo, mejora mensajes de consola y notificaciones en escritorio
  */

  ///////////////////////////////////////////////////////////////////////////

    function wait(ms) {
        var start = new Date().getTime();
        var end = start;
        while (end < start + ms) {
            end = new Date().getTime();
        }
    }

    var box = (lines, l) => {
        l = Math.abs(l);

        for (let i = 0; i < lines.length; i++) {
            let a = (lines[i] = lines[i].trimRight()).length;
            l = a > l ? a : l;
        }

        var header = '+' + '='.repeat(l) + '+';
        var output = '';

        output += header + '\n';
        for (let i = 0; i < lines.length; i++) {
            let a = lines[i].length;
            output += '|' + lines[i] + ' '.repeat(l - a) + '|\n';
        }

        output += header;
        return output;

    };

    var cinf = (...a) => console.info(...a);
    var cerr = (...a) => console.error(...a);
    var clog = (...a) => console.log(...a);

    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);
    }

  ///////////////////////////////////////////////////////////////////////////

  /*
  Info en consola
  */

  ///////////////////////////////////////////////////////////////////////////

    cinf(box([
        'SocialAnime tools:',
        '',
        'Ver: ' + GM_info.script.version,
        'By ' + GM_info.script.author,
        '',
    ], 40));
    clog('[+] El Script empieza');

  ///////////////////////////////////////////////////////////////////////////

  /*
  Refrescar pagina al dar al logo
  */

  ///////////////////////////////////////////////////////////////////////////

    $(document).on('click', '.sa-header__logo-desktop', function () {
        location.reload();
    });

    $(document).on('click', '.sa-main-menu__logo', function () {
        location.reload();
    });
})();