File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// ==UserScript==
22// @name Codingame File Sync
3- // @match *://code .codingame.com/*
4- // @version 1.0
3+ // @match *://www .codingame.com/ide /*
4+ // @version 1.1
55// @grant none
66// ==/UserScript==
77
88( function ( ) {
99 setInterval ( function ( ) {
10- $ ( "#inputParent > div.squareTitle > div.tools " )
10+ $ ( ".code-buttons " )
1111 . filter ( function ( ) {
1212 return ! ( $ ( this ) . data ( "syncInputOk" ) === true ) ;
1313 } )
1717 . prepend ( "<div><form><input type=\"file\" class=\"syncInput\" /></form></div>" ) ;
1818 } ) ;
1919
20- $ ( "#inputParent div.squareTitle > div.tools form > input .syncInput" ) . each ( function ( ) {
20+ $ ( ".syncInput" ) . each ( function ( ) {
2121 var reader = new FileReader ( ) ;
22- var parent = $ ( this ) . closest ( "#inputParent" ) ;
23- var prevCode = parent . data ( "code" ) || "" ;
22+ var prevCode = "" ;
2423
2524 if ( this . files . length != 1 ) {
2625 return ;
2726 }
2827
2928 reader . onloadend = function ( ) {
3029 var code = reader . result . replace ( / \r \n / g, '\n' ) . replace ( / \r / g, '\n' ) ;
31- var event = new CustomEvent ( 'IDE_SendRequest ' , {
30+ var event = new CustomEvent ( 'ExternalEditorToIDE ' , {
3231 'detail' : {
33- 'status' : "SendCodeViaPlugin " ,
32+ 'status' : "updateCode " ,
3433 'code' : code
3534 }
3635 } ) ;
3736
3837 if ( prevCode != code ) {
39- $ ( window . top . document )
40- . find ( "#ideFrame" )
41- . contents ( ) [ 0 ]
42- . dispatchEvent ( event ) ;
38+ window . document . dispatchEvent ( event ) ;
4339
44- parent . data ( "code" , code ) ;
40+ prevCode = code ;
4541 }
4642 } ;
4743
4844 reader . readAsText ( this . files [ 0 ] ) ;
4945 } ) ;
5046 } , 1000 ) ;
5147} ) ( ) ;
48+
You can’t perform that action at this time.
0 commit comments