Skip to content

Instantly share code, notes, and snippets.

@Timur00Kh
Last active October 4, 2022 19:35
Show Gist options
  • Save Timur00Kh/6af4b541a11f9df9b39989f3a29f6ae0 to your computer and use it in GitHub Desktop.
Save Timur00Kh/6af4b541a11f9df9b39989f3a29f6ae0 to your computer and use it in GitHub Desktop.
Скрипт для препода робокода.
// ==UserScript==
// @name Learn innopolis
// @namespace https://hrum.it/
// @version 0.5
// @description Скрипт для препода робокода.
// @author Timur00Kh
// @match https://learn.innopolis.university/Instructors/Trainings/**
// @icon https://learn.innopolis.university/favicon.ico
// @grant none
// @updateURL https://gist.githubusercontent.com/Timur00Kh/6af4b541a11f9df9b39989f3a29f6ae0/raw/learn-innopolis.user.js
// @downloadURL https://gist.githubusercontent.com/Timur00Kh/6af4b541a11f9df9b39989f3a29f6ae0/raw/learn-innopolis.user.js
// @homepageURL https://gist.github.com/Timur00Kh/6af4b541a11f9df9b39989f3a29f6ae0
// @supportURL https://gist.github.com/Timur00Kh/6af4b541a11f9df9b39989f3a29f6ae0
// ==/UserScript==
(function() {
'use strict';
let injected = false;
const userIndex = 4;
const styles = `
#students {
position: relative;
}
#students thead tr {
position: sticky;
top: 0;
background: white;
}
#students thead tr:last-child {
top: 51px;
}
#students thead tr:first-child th:nth-child(2) {
left: 0;
position: sticky;
z-index: 2;
background: white;
}
#students thead tr:first-child {
z-index: 2;
}
#students tr td:nth-child(2) {
left: 0;
position: sticky;
}
#students tr:nth-child(odd) td:nth-child(2) {
background: #f2f2f2;
}
#students tr:nth-child(even) td:nth-child(2) {
background: white;
}
`;
function tryInject() {
if (!document.querySelector('#students_wrapper')) return;
document.querySelector(`#bs-select-2-${userIndex}`).click();
Array.from(document
.querySelectorAll('#students > thead > tr:nth-child(2) > th'))
.forEach((e, i) => (e.innerText = i));
const styleSheet = document.createElement("style");
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);
injected = true;
}
const interval = setInterval(() => {
if (injected) {
clearInterval(interval);
} else {
tryInject();
}
}, 1000)
document.addEventListener('load', () => {
tryInject();
})
window.addEventListener('keypress', (e) => {
if (e.key === "Enter") {
document.getElementById('evaluation-save')?.click();
}
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment