Further refinements to Codersrank handling
This commit is contained in:
@@ -36,3 +36,28 @@
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
function prepareCodersrank(type) {
|
||||
var placeholders = document.getElementsByClassName("cr-placeholder");
|
||||
if (localStorage.getItem("load-codersrank")) {
|
||||
loadCodersrank(type);
|
||||
} else {
|
||||
for (ph of placeholders) {
|
||||
ph.addEventListener("click", e => {
|
||||
e.preventDefault();
|
||||
console.log(e);
|
||||
localStorage.setItem("load-codersrank", true);
|
||||
loadCodersrank(type);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadCodersrank(type) {
|
||||
var script = document.createElement("script");
|
||||
script.src = "https://unpkg.com/@codersrank/activity/codersrank-" + type + ".min.js";
|
||||
for (ph of document.getElementsByClassName("cr-placeholder")) {
|
||||
ph.parentElement.innerHTML = ph.childNodes[0].data;
|
||||
}
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user