Skip to content

Commit 60ed004

Browse files
committed
Merge pull request #1 from MaximeCheramy/master
Update to work with the new IDE.
2 parents 0c3f923 + ba2f877 commit 60ed004

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

codingame-sync.user.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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
})
@@ -17,35 +17,32 @@
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+

0 commit comments

Comments
 (0)