Skip to content

Instantly share code, notes, and snippets.

@pavi2410
Forked from digi0ps/skillhack.js
Last active November 17, 2021 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavi2410/036d4740f0d71cbe780cdf7b052d5b05 to your computer and use it in GitHub Desktop.
Save pavi2410/036d4740f0d71cbe780cdf7b052d5b05 to your computer and use it in GitHub Desktop.
Hack for skillrack copy paste
// just call auto() in console for each problem in programming track.
// Use this extension to load this script
// https://microsoftedge.microsoft.com/addons/detail/koccodmekleicmjpnelamemnhkpbkibc
function solve(code) {
var editor_id = $(".ace_editor.ace_dark")[0].id;
var editor = ace.edit(editor_id);
editor.$blockScrolling = Infinity;
// editor.session.setValue(sol)
// editor.$handlePaste(CODE[0])
// var sol = $('#solutionDialog_content').text()
var sol = code ? code[0] : $('#hintDialog_content > pre').text()
var lines = sol.trim().split(/\n/).map(it => it.trim()).filter(it => it != '')
editor.setValue("");
lines.forEach((l, i) => {
editor.insert(l + "\n");
var row = editor.session.getLength() - 1;
var column = editor.session.getLine(row).length;
editor.gotoLine(row + 1, column);
})
}
function auto() {
PrimeFaces.ab({s:"j_id_63",f:"code",p:"j_id_63",u:"codeeditorpanel"})
.then(() => $("button:contains('View Solution')").click())
.then(() => $(".hljs.cpp")[0].textContent)
.then((c) => solve([c]))
.then(() => $("button:contains('Run')").click())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment