Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    bleush
    @bleush38p
    what have you forgotten?
    MegaApuTurkUltra
    @MegaApuTurkUltra
    idk
    bleush
    @bleush38p
    ext._getStatus (arguably part of the descriptor, so maybe you didn't forget it)
    It's a function
    And it runs as soon as the extension gets loaded, if it does.
    (I might be wrong about some names, I'm doing this clumsily on a phone on a bus)
    And also do please hold, we're passing some portals and it's 1.5x AP
    MegaApuTurkUltra
    @MegaApuTurkUltra
    portals?
    is it the future already? :P
    bleush
    @bleush38p
    Ingress
    And okay I'm back
    Anyway
    Set up some global callback (object?)
    And then call extensionLoaded["my_awesome_extension "]() in _getStatus
    Back over in not-extension-land
    MegaApuTurkUltra
    @MegaApuTurkUltra
    hmm
    interesting
    bleush
    @bleush38p
    We're loading the extension repeatedly (1s?) Until the callback calls back
    MegaApuTurkUltra
    @MegaApuTurkUltra
    ?
    bleush
    @bleush38p
    And then we know scratch is there. So either we've confirmed the extension was loaded or we know scratch is, then we can remove the temporary one and load a real one
    MegaApuTurkUltra
    @MegaApuTurkUltra
    This message was deleted
    I see
    I was confused :P
    bleush
    @bleush38p
    Thats the opposite problem :P
    MegaApuTurkUltra
    @MegaApuTurkUltra
    just use nxIII's hack
    bleush
    @bleush38p
    And yes
    MegaApuTurkUltra
    @MegaApuTurkUltra
    it hasn't failed me yet :P
    bleush
    @bleush38p
    What's that?
    I'm sure I've seen it before, but it's not coming to me now and I'm sure as hell not trying to find it with a phone :P
    MegaApuTurkUltra
    @MegaApuTurkUltra
    var old = window.JSsetProjectStats;
      if (old) {
        var times = 0;
        window.JSsetProjectStats = function() {
          old.apply(this, arguments);
          if (times++){
              // scratch loaded
          }
        };
    bleush
    @bleush38p
    Ahhh
    Let's see
    Very technical
    I'll have to play with that
    MegaApuTurkUltra
    @MegaApuTurkUltra
    of course this is a problem if multiple extensions try to do it at the same time
    that's why I made my extension loader
    no extension userscripts needed. It detects extensions in the project code and loads them
    // ==UserScript==
    // @name         Extension Loader
    // @version      0.1
    // @description  Loads extensions saved in Scratch projects
    // @author       MegaApuTurkUltra & nXIII (mostly nXIII :P)
    // @match        http://scratch.mit.edu/projects/*
    // @match        https://scratch.mit.edu/projects/*
    // @run-at       document-end
    // @grant        none
    // ==/UserScript==
    
    var script = document.createElement('script');
    script.id = "swag";
    script.textContent = '('+function() {
      var old = window.JSsetProjectStats;
      if (old) {
        var times = 0;
        window.JSsetProjectStats = function() {
          old.apply(this, arguments);
          if (times++){
              var id = location.pathname.match(/[0-9]+/)[0];
              $.get("https://cdn.projects.scratch.mit.edu/internalapi/project/"+id+"/get/", function(data){
                  if(data.info.hasOwnProperty("savedExtensions")){
                      for(var x in data.info.savedExtensions){
                          if(!confirm("Load extension '" + data.info.savedExtensions[x].extensionName + "'?") continue;
                          console.log("EXTENSION LOADER: loading extension", data.info.savedExtensions[x].extensionName);
                          ScratchExtensions.loadExternalJS(data.info.savedExtensions[x].javascriptURL);
                      }
                  }
              });
          }
        };
      }
    }+')()';
    
    document.body.appendChild(script);
    this
    bleush
    @bleush38p
    Wow
    Granted, I'd be a little scared to use that as there's no confirmation or anything, and I don't really want anyone loading any code from anywhere to run in Scratch's context
    MegaApuTurkUltra
    @MegaApuTurkUltra
    good point
    see it now ^^
    what about that
    bleush
    @bleush38p
    Ugh, confirm :P
    It'll do, certainly
    That's partially why easyextend needs a manifest for each extension
    bleush
    @bleush38p
    hey, apu
    you know what's a pain?