KodeItDEV / Super Scratch

/* globals GM_config */
// ==UserScript==
// @name         Super Scratch
// @namespace    http://tampermonkey.net/
// @version      0.1
// @updateURL    https://openuserjs.org/meta/KodeItDEV/Super_Scratch.meta.js
// @description  Installs any given Scratch Extension to the website
// @author       KodeItDEV
// @icon         https://scratch.mit.edu/favicon.ico
// @include      https://scratch.mit.edu/*
// @require      https://raw.githubusercontent.com/eight04/GM_config/master/dist/GM_config.js
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand
// @grant        GM_notification
// @grant        unsafeWindow
// @run-at       document-idle
// @license      MIT
// @copyright    2017, KodeItDEV (https://openuserjs.org/users/KodeItDEV)
// ==/UserScript==

// I DO NOT OWN THE ICON. All rights to the icon go to Scratch and MIT. // 

GM_registerMenuCommand('SScratch Settings', settings);

GM_config.init( 'Super Scratch', {
    scripts: {
        label: "Paste all of the scripts you want to load below, with each script on a separate line.",
        type: "textarea",
        default: "https://rawgit.com/Iwotastic/Scratch-Boost/master/src/installer.js"
    }
});

if (window.location.pathname.indexOf("projects") >= 0) {

    setTimeout(function loadjs() {
        try {
            var sscripts = GM_getValue('sscripts');
            for (var x in sscripts) {
                var s = document.createElement('script');
                s.setAttribute('src', sscripts[x].replace("http:", "https:"));
                document.body.appendChild(s);
                //alert(sscripts[x]);
            }
        } catch(err) {
            GM_notification("You're scripts don't seem to be loading...\nYou may need to allow unsafe scripts.");
        }
    }, 5000);

    GM_config.onclose = (function(saveFlag) {
        if (saveFlag) {
            var scripts = GM_config.get('scripts').split('\n');
            GM_setValue('sscripts', scripts);
            if (confirm('Please refresh the page to load your scripts')) {
                location.reload();
            }
        }
    });

}

function settings() {
    GM_config.open();
}