SuperHal989

Extension Extension

Sep 17th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.55 KB | None | 0 0
  1. (function (ext) {
  2. var ExtName = 'Extension Extension';
  3. ext._shutdown = function() {};
  4. ext._getStatus = function() {
  5. return {status: 2, msg: 'Ready'};
  6. };
  7. var descriptor = {
  8. blocks: [
  9. [' ', 'Install Speech Extension', 'secId1'],
  10. [' ', 'Install MiniNinja Extension', 'secId2'],
  11. [' ', 'Install Browser Stuff Extension', 'secId3'],
  12. [' ', 'Install Temp Vars & Lists Extension', 'secId4'],
  13. [' ', 'Install Browser Extension', 'secId5'],
  14. [' ', 'Install VarExt Extension', 'secId6'],
  15. ],
  16. menus: {
  17. },
  18. url: ''
  19. };
  20. ext.secId1 = function(ext,callback){
  21. javascript:new(function(){var ext=this;var recognized_speech=\'\';ext.recognize_speech=function(callback){var recognition=new webkitSpeechRecognition();recognition.onresult=function(event){if(event.results.length>0){recognized_speech=event.results[0][0].transcript;if(typeof callback=="function")callback()}};recognition.start()};ext.recognized_speech=function(){return recognized_speech};ext._shutdown=function(){};ext._getStatus=function(){if(window.webkitSpeechRecognition===undefined){return{status:1,msg:\'Your browser does not support speech recognition. Try using Google Chrome.\'}}return{status:2,msg:\'Ready\'}};var descriptor={blocks:[[\'w\',\'wait and recognize speech\',\'recognize_speech\'],[\'r\',\'recognized speech\',\'recognized_speech\']],};ScratchExtensions.register(\'Speech To Text\',descriptor,ext)})();new(function(){var ext=this;ext.speak_text=function(text,callback){var u=new SpeechSynthesisUtterance(text.toString());u.onend=function(event){if(typeof callback=="function")callback()};speechSynthesis.speak(u)};ext._shutdown=function(){};ext._getStatus=function(){if(window.SpeechSynthesisUtterance===undefined){return{status:1,msg:\'Your browser does not support text to speech. Try using Google Chrome or Safari.\'}}return{status:2,msg:\'Ready\'}};var descriptor={blocks:[[\'w\',\'speak %s\',\'speak_text\',\'Hello!\'],],};ScratchExtensions.register(\'Text to Speech\',descriptor,ext)})();new(function(){var ext=this;ext._shutdown=function(){};ext._getStatus=function(){return{status:2,msg:\'Ready\'}};ext.trueBlock=function(){return true};var descriptor={blocks:[[\'b\',\'true\',\'trueBlock\'],]};ScratchExtensions.register(\'extension registered?\',descriptor,ext)})();
  22. callback();
  23. };
  24. ext.secId2 = function(ext,callback){
  25. javascript:(function(){var s=document.createElement(\'script\');s.setAttribute(\'src\',\'https://pastebin.com/raw.php?i=vaAL71rg\');document.body.appendChild(s);}());
  26. callback();
  27. };
  28. ext.secId3 = function(ext,callback){
  29. (function(ext) { ext.alert = function(message) { alert(message); }; ext.confirm = function(question) { return confirm(question); }; ext.ask = function(question) { return prompt(question); }; ext.setTitle = function(title) { window.document.title = title; }; ext.openTab = function(location) { window.open(location, \'_blank\'); }; ext._shutdown = function() { console.log(\'Shutting down...\'); }; ext._getStatus = function() { return {status: 2, msg: \'Ready\'}; }; var descriptor = { blocks: [ [\' \', \'alert %s\', \'alert\', \'\'], [\'b\', \'confirm %s\', \'confirm\', \'Are you sure?\'], [\'r\', \'ask %s\', \'ask\', \'How are you?\'], [\' \', \'set window title to %s\', \'setTitle\', \'title\'], [\' \', \'open tab with %s\', \'openTab\', \'https://twitter.com/scratchteam\'] ] }; ScratchExtensions.register(\'Browser Stuff (ScratchX)\', descriptor, ext);})({});
  30. callback();
  31. };
  32. ext.secId4 = function(ext,callback){
  33. (function (ext) { ext._getStatus = function() { return { status: 2, msg: \'Ready\' }; }; ext._shutdown = function() { }; ext.installed = function() { return true; }; ext.var_get = function(v) { return ExtVars[v]; }; ext.var_new = function(v) { ExtVars[v] = ""; }; ext.var_set = function(v,value) { ExtVars[v] = value; }; ext.var_change = function(v,value) { ExtVars[v] += value; }; ext.var_del = function(v) { ExtVars.del(v); }; ext.list_get = function(list) { return ExtLists[list].join(" "); }; ext.list_get_item = function(idx,list) { return ExtLists[list][idx-1]; }; ext.list_length = function(list) { return ExtLists[list].length(); }; ext.list_new = function(list) { ExtLists[list] = []; }; ext.list_add = function(list,item) { ExtLists[list].push(item); }; ext.list_replace = function(idx,list,item) { ExtLists[list][idx-1] = item; }; ext.list_insert = function(item,idx,list) { ExtLists[list].splice(idx-1,0,item); }; ext.list_del_item = function(idx,list) { ExtLists[list].del(idx); }; ext.list_del = function(list) { ExtLists.del(list); }; var ExtVars = {}; var ExtLists = {}; var descriptor = { blocks: [ [\'b\', \'temp vars extension installed?\',\'installed\' ], [\'r\', \'get variable %s\', \'var_get\', \'\'], [\' \', \'create variable %s\', \'var_new\', \'\'], [\' \', \'set %s to %s\', \'var_set\', \'\', \'\'], [\' \', \'change %s by %n\', \'var_change\', \'\',1], [\' \', \'delete variable %s\', \'var_del\', \'\'], [\'r\', \'get list %s\', \'list_get\', \'\'], [\'r\', \'item %n of %s\', \'list_get_item\',\'1\',\'\'], [\'r\', \'length of %s\', \'list_length\', \'\'], [\' \', \'create list %s\', \'list_new\', \'\'], [\' \', \'add %s to %s\', \'list_add\', \'\',\'\'], [\' \', \'replace %n of %s with %s\', \'list_replace\',1,\'\',\'\'], [\' \', \'insert %s at %n of %s\', \'list_insert\', \'\',1,\'\'], [\' \', \'delete %n of %s\', \'list_del_item\', 1,\'\'], [\' \', \'delete list %s\', \'list_del\', \'\'] ], }; ScratchExtensions.register(\'Temp Vars and Lists\', descriptor, ext);})({});
  34. callback();
  35. };
  36. ext.secId5 = function(ext,callback){
  37. (function(ext) { ext._shutdown = function() {}; ext._getStatus = function() { return {status: 2, msg: \'Ready\'}; }; ext.oldUrl = \'\'; ext.show = function(t, l, w, h) { ext.iframe = document.createElement(\'iframe\'); ext.iframe.style.position = \'absolute\'; ext.iframe.style.top = t + \'px\'; ext.iframe.style.left = l + \'px\'; ext.iframe.style.width = w + \'px\'; ext.iframe.style.height = h + \'px\'; ext.iframe.style.backgroundColor = \'#FFFFFF\'; ext.iframe.src = \'about:blank\'; document.body.appendChild(ext.iframe); }; ext.hide = function() { document.body.removeChild(ext.iframe); }; ext.goTo = function(newUrl) { ext.iframe.src = newUrl; }; ext.getUrl = function() { var url = \'\'; try { url = ext.iframe.contentWindow.location.href; } catch(e) { url = ext.iframe.src; } return url; }; var descriptor = { blocks: [ [\' \', \'show with top %n left %n width %n height %n\', \'show\', 0, 0, 480, 360], [\' \', \'hide\', \'hide\'], [\' \', \'go to %s\', \'goTo\', \'http://scratchx.org/\'], [\'r\', \'url\', \'getUrl\'] ] }; ScratchExtensions.register(\'Web\', descriptor, ext);})({});
  38. callback();
  39. };
  40. ext.secId6 = function(ext,callback){
  41. (function(ext) { ext._shutdown = function() {}; ext._getStatus = function() { return { status: 2, msg: \'Unstable\' } }; var varHolder = {}; var descriptor = { blocks: [ [\' \', \'create var %s and set it to %s\', \'set\', \'var\', \'0\'], [\' \', \'change var %s by %n\', \'change\', \'\', 1], [\'r\', \'%s\', \'get\', \'\'] ], menus: { } }; ext.set = function(variable, val) { console.log("set"); varHolder[variable] = val; }; ext.change = function(variable, val) { console.log("change"); varHolder[variable] = varHolder[variable] + val; }; ext.get = function(variable) { console.log("get"); return varHolder[variable]; }; ScratchExtensions.register(\'VarExt\', descriptor, ext);})({});
  42. callback();
  43. };
  44. ScratchExtensions.register(ExtName, descriptor, ext);
  45. })({});
Add Comment
Please, Sign In to add comment