// ==UserScript== // @name Open in Miru // @namespace http://tampermonkey.net/ // @version 1.0 // @description Adds a link to open an anime in Miru, if you have MAL-Sync installed then it will be at the bottom of the Quicklinks. // @author WhiteTapeti // @match https://anilist.co/* // @icon https://raw.githubusercontent.com/ThaUnknown/miru/master/docs/logo.png // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js // @require https://openuserjs.org/src/libs/sizzle/GM_config.js // @grant GM_getValue // @grant GM_setValue // @grant GM.getValue // @grant GM.setValue // @grant GM_addStyle // @grant GM_registerMenuCommand // @downloadURL none // ==/UserScript== var quicklinkPosition = ''; async function quicklinkSettings() { let MiruQuicklinkConfigFrame = document.createElement('div'); document.body.appendChild(MiruQuicklinkConfigFrame); let gmc = new GM_config({ 'id': 'MiruLinkConfig', // The id used for this instance of GM_config 'title': 'Miru Quicklink Settings', // Panel Title 'fields': // Fields object { 'Name': // This is the id of the field { 'label': 'Quicklink Position (only changes the position if Mal-Sync is installed)', // Appears next to field 'type': 'select', // Makes this setting a dropdown 'options': ['Bottom', 'Top'], // Possible choices 'default': 'Bottom' // Default value if user doesn't change it } }, 'events': { 'init': function() { // runs after initialization completes }, 'save': function() { // runs after values are saved // log the saved value of the Name field this.log(this.get('Name')); quicklinkPosition = this.get('Name'); if (window.location.href.indexOf('https://anilist.co/anime/') == 0) { setTimeout(function() { if (document.body.contains(document.getElementById("MiruLinks")) == true) { document.getElementById("MiruLinks").remove(); } }, 1500); } } }, 'css': '#MiruLinkConfig *{font-family:arial,tahoma,myriad pro,sans-serif;color-scheme:dark!important}#MiruLinkConfig{background:#fff}#MiruLinkConfig .field_label{font-size:large;font-weight:700;margin-right:6px}a#MiruLinkConfig_resetLink{text-decoration:underline}#MiruLinkConfig .block{display:block}#MiruLinkConfig .saveclose_buttons{margin:16px 10px 10px;padding:2px 12px}#MiruLinkConfig .reset,#MiruLinkConfig_buttons_holder{color:#000;text-align:right}#MiruLinkConfig .config_header{font-size:20pt;margin:0}#MiruLinkConfig .reset{font-size:9pt}#MiruLinkConfig .center{text-align:center}#MiruLinkConfig .section_header_holder{margin-top:8px}#MiruLinkConfig .config_var{margin:0 0 4px}/*! CSS Used from: Embedded ; media=screen *//*! CSS Used from: Embedded ; media=screen */@media screen{:root{neutral-background:#131516;neutral-text:#d8d4cf;selection-background:#004daa;selection-text:#e8e6e3}div#MiruLinkConfig{border-color:#736b5e;color:#e8e6e3}::placeholder{color:#b2aba1;opacity:.5!important}::-webkit-scrollbar{background-color:#202324;color:#aba499}::-webkit-scrollbar-thumb{background-color:#454a4d}::-webkit-scrollbar-thumb:hover{background-color:#575e62}::-webkit-scrollbar-thumb:active{background-color:#484e51}::-webkit-scrollbar-corner{background-color:#181a1b}::selection{background-color:#004daa!important;color:#e8e6e3!important}#MiruLinkConfig{background-image:initial;background-color:#151f2e}#MiruLinkConfig .reset,#MiruLinkConfig_buttons_holder{color:#e8e6e3}button#MiruLinkConfig_closeBtn,button#MiruLinkConfig_saveBtn{background-color:#3db4f2}}', 'frame': MiruQuicklinkConfigFrame }); await gmc.initialized; quicklinkPosition = gmc.get('Name'); GM_registerMenuCommand('Configure Miru Quicklink', () => { gmc.open() }); console.log('Saved position is ' + quicklinkPosition); var functionIsRunning = false; document.body.onload = function() { if (window.location.href.indexOf('https://anilist.co/anime/') == 0) { setTimeout(function() { if (document.body.contains(document.getElementById("MiruLinks")) == false) { if (!functionIsRunning) { functionIsRunning = true; console.log('dsa'); if (quicklinkPosition == 'Bottom') { $(`
`).insertBefore(".data"); } else { $(``).insertAfter(".rankings"); } functionIsRunning = false; } } }, 1500); } } window.addEventListener('popstate', (event) => { if (window.location.href.indexOf('https://anilist.co/anime/') == 0) { setTimeout(function() { if (document.body.contains(document.getElementById("MiruLinks")) == false) { if (!functionIsRunning) { functionIsRunning = true; console.log('dsa'); if (quicklinkPosition == 'Bottom') { $(``).insertBefore(".data"); } else { $(``).insertAfter(".rankings"); } functionIsRunning = false; } } }, 1500); } }); window.addEventListener('locationchange', function() { if (window.location.href.indexOf('https://anilist.co/anime/') == 0) { setTimeout(function() { if (document.body.contains(document.getElementById("MiruLinks")) == false) { if (!functionIsRunning) { functionIsRunning = true; console.log('dsa'); if (quicklinkPosition == 'Bottom') { $(``).insertBefore(".data"); } else { $(``).insertAfter(".rankings"); } functionIsRunning = false; } } }, 1500); } }); $(document).click(function() { if (window.location.href.indexOf('https://anilist.co/anime/') == 0) { setTimeout(function() { if (document.body.contains(document.getElementById("MiruLinks")) == false) { if (!functionIsRunning) { functionIsRunning = true; console.log('dsa'); if (quicklinkPosition == 'Bottom') { $(``).insertBefore(".data"); } else { $(``).insertAfter(".rankings"); } functionIsRunning = false; } } }, 1500); } }); } quicklinkSettings();