Created
June 6, 2015 17:20
-
-
Save Catsync/4067ce1b69bb1dfb86d2 to your computer and use it in GitHub Desktop.
Put this in the chrome dev tools under Sources -> Snippets. Use when your referee's setUpLevel code prevents loading your level in the editor. It'll add "{}" to the end of your referee's extraCode, which you can remove after you've fixed it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(currentView) { | |
var thangs = currentView.level.get('thangs'); | |
var refereeThang = null; | |
for(var i=0; i < thangs.length; i++) { | |
var thang = thangs[i]; | |
if(thang.components) { | |
for(var j=0; j < thang.components.length; j++) { | |
var component = thang.components[j]; | |
if(component.config && component.config.extraCode) { | |
refereeThang = thang; | |
refereeCode = component.config.extraCode; | |
component.config.extraCode = refereeCode + '\n{}'; | |
console.log('Found referee, commenting out extraCode'); | |
currentView.level.set('thangs',thangs); | |
break; | |
} | |
} | |
} | |
if(refereeThang !== null) { | |
break; | |
} | |
} | |
if(refereeThang === null) { | |
console.log("Referee not found."); | |
} | |
})(currentView); |
Using Safari's Web Inspector the following HTML can be injected into the broken page. Creating an easy click button to run the above code. This should work on Firefox as well.
<button onclick="var t = currentView.level.get('thangs');var r = null;for(var i=0; i < t.length; i++) {var h = t[i];if(h.components) {for(var j=0; j < h.components.length; j++) {var c = h.components[j];if(c.config && c.config.extraCode) {r = h;var e = c.config.extraCode;c.config.extraCode = e + '\n{}';console.log('Found referee, commenting out extraCode');currentView.level.set('thangs',t);break;}}}if(r !== null) {break;}}if(r === null) {console.log('Referee not found.');}">Click to Fix the referee Code</button><p>Then refresh the browser page</p>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you can't load the level at all due to an infinite loop in
setUpLevel
, then you can get to the thangs from any other page on codecombat.com like this:You could then adapt this script to
JSON.stringify()
the updated level and put it in localStorage with that cache key.