Skip to content

Instantly share code, notes, and snippets.

@Ch-sriram
Last active July 26, 2023 00:43
Show Gist options
  • Save Ch-sriram/f0fce204ac812875f0e131796e46ba89 to your computer and use it in GitHub Desktop.
Save Ch-sriram/f0fce204ac812875f0e131796e46ba89 to your computer and use it in GitHub Desktop.
WES iGPA Automated Score Filler And Calculator
/*
Paste the methods below in Chrome Console (Ctrl + Shift + I), and then convert the data into JSON string using:
JSON.stringify(data);
Paste that string as a parameter to `prefillSubjectsAndGrades` method.
Example is given at the end of this file.
NOTE: If the fields change (their `id` values in particular), then the algorithm will break, and is rendered useless.
*/
/*
v2: Faster Version to Use
*/
const prefillSubjectsAndGradesFaster = async jsonString => {
const addCourseBtn = document.querySelector('input[value="Add Course"]');
const subjectsAndGradesList = JSON.parse(jsonString);
const blurEvent = new Event('blur');
subjectsAndGradesList.forEach(async(ele, idx) => {
const allKeys = Object.keys(ele);
for (key of allKeys) {
document.querySelector(`#${key}${idx+1}`).value = ele[key];
if (key.includes('credit')) {
(document.querySelector(`#credit${idx+1}`)).dispatchEvent(blurEvent);
await new Promise(r => setTimeout(r, 500));
}
}
await new Promise(r => setTimeout(r, 500));
addCourseBtn && addCourseBtn.click();
})
}
/*
v1: slow, but catches any errors, and users have a chance to fix the errors
*/
/*
function* newSubjectAndGradeGenerator(subjectAndGradeList) {
for (let i = 0; i < subjectAndGradeList.length; ++i) {
yield {index: i, ...subjectAndGradeList[i]};
}
}
const prefillSubjectsAndGrades = async jsonString => {
const addCourseBtn = document.querySelector('input[value="Add Course"]');
const subjectsAndGradesList = JSON.parse(jsonString);
const generateNewSubjectAndGrade = newSubjectAndGradeGenerator(subjectsAndGradesList);
let areThereMoreToYield = true;
while(areThereMoreToYield) {
try {
const {index, ...subjectAndGrade} = generateNewSubjectAndGrade.next().value;
const allKeys = Object.keys(subjectAndGrade);
for (key of allKeys) {
if (key.includes('num_grd')) {
await new Promise(r => setTimeout(r, 2000));
}
document.querySelector(`#${key}${index+1}`).value = subjectAndGrade[key];
}
await new Promise(r => setTimeout(r, 1000));
addCourseBtn && addCourseBtn.click();
} catch(e) {
console.log("Iteration Stopped", e);
areThereMoreToYield = false;
}
}
}
*/
const data = [
{
title: 'ENGLISH',
credit: 100,
num_grd: 66
},
{
title: 'MATHEMATICS - I',
credit: 100,
num_grd: 56
},
{
title: 'MATHEMATICS - II',
credit: 100,
num_grd: 62
},
{
title: 'ENGINEERING PHYSICS',
credit: 100,
num_grd: 50,
},
{
title: 'PHYSICS LAB',
credit: 75,
num_grd: 68,
},
{
title: 'ENGINEERING CHEMISTRY',
credit: 100,
num_grd: 63,
},
{
title: 'CHEMISTRY LAB',
credit: 75,
num_grd: 57,
},
{
title: 'ENGINEERING GRAPHICS',
credit: 150,
num_grd: 89,
},
{
title: 'WORKSHOP PRACTICE',
credit: 100,
num_grd: 67,
},
{
title: 'ENGINEERING MECHANICS',
credit: 100,
num_grd: 46,
},
{
title: 'PROGRAMMING IN C & C++',
credit: 100,
num_grd: 78,
},
{
title: 'PROGRAMMING LAB',
credit: 75,
num_grd: 74,
},
{
title: 'ENGLISH LANGUAGE LAB',
credit: 75,
num_grd: 69,
},
{
title: 'MATHEMATICS - III',
credit: 100,
num_grd: 63,
},
{
title: 'DATA STRUCTURES USING C++',
credit: 100,
num_grd: 73,
},
{
title: 'DISCRETE STRUCTURES',
credit: 100,
num_grd: 62,
},
{
title: 'LOGIC & SWITCHING THEORY',
credit: 100,
num_grd: 59,
},
{
title: 'COMPUTER ARCHITECTURE',
credit: 100,
num_grd: 78,
},
{
title: 'BASIC ELECTRONICS',
credit: 100,
num_grd: 68,
},
{
title: 'DATA STRUCTURES LAB USING C++',
credit: 75,
num_grd: 70,
},
{
title: 'BASIC ELECTRONICS LAB',
credit: 75,
num_grd: 60,
},
{
title: 'MATHEMATICS - IV',
credit: 100,
num_grd: 44,
},
{
title: 'OOP USING JAVA',
credit: 100,
num_grd: 76,
},
{
title: 'MICROPROCESSORS & INTERFACING',
credit: 100,
num_grd: 53,
},
{
title: 'DATA COMMUNICATIONS',
credit: 100,
num_grd: 49,
},
{
title: 'ELECTRICAL CIRCUITS & MACHINES',
credit: 100,
num_grd: 42,
},
{
title: 'ENVIRONMENTAL STUDIES',
credit: 100,
num_grd: 73,
},
{
title: 'JAVA PROGRAMMING LAB',
credit: 75,
num_grd: 68,
},
{
title: 'MICROPROCESSOR LAB',
credit: 75,
num_grd: 53,
},
{
title: 'DATABASE MANAGEMENT SYSTEMS',
credit: 100,
num_grd: 72,
},
{
title: 'OPERATING SYSTEMS',
credit: 100,
num_grd: 61,
},
{
title: 'AUTOMATA, LANGUAGES AND COMPUTATION',
credit: 100,
num_grd: 72,
},
{
title: 'SOFTWARE ENGINEERING',
credit: 100,
num_grd: 55,
},
{
title: 'MANAGERIAL ECONOMICS & ACCOUNTANCY',
credit: 100,
num_grd: 67,
},
{
title: 'DESIGN & ANALYSIS OF ALGORITHMS',
credit: 100,
num_grd: 66,
},
{
title: 'DATABASE MANAGEMENT SYSTEM LAB',
credit: 75,
num_grd: 69,
},
{
title: 'OPERATING SYSTEMS LAB',
credit: 100,
num_grd: 66
},
{
title: 'MINI PROJECT',
credit: 25,
num_grd: 22,
},
{
title: 'WEB PROGRAMMING & SERVICES',
credit: 100,
num_grd: 65,
},
{
title: 'COMPILER CONSTRUCTION',
credit: 100,
num_grd: 75
},
{
title: 'PRINCIPLES OF PROGRAMMING LANGUAGES',
credit: 100,
num_grd: 58,
},
{
title: 'OBJECT ORIENTED SYSTEMS DEVELOPMENT',
credit: 100,
num_grd: 78
},
{
title: 'COMPUTER NETWORKS',
credit: 100,
num_grd: 49
},
{
title: 'WPS & CN LAB',
credit: 75,
num_grd: 56
},
{
title: 'OOSD LAB',
credit: 75,
num_grd: 51,
},
{
title: 'COMPILER CONSTRUCTION LAB',
credit: 100,
num_grd: 51
},
{
title: 'MINI PROJECT',
credit: 25,
num_grd: 10,
},
{
title: 'DISTRIBUTED SYSTEMS',
credit: 100,
num_grd: 71,
},
{
title: 'ARTIFICIAL INTELLIGENCE',
credit: 100,
num_grd: 70
},
{
title: 'INFORMATION SECURITY',
credit: 100,
num_grd: 64
},
{
title: 'PRINCIPLES & APPLICATIONS OF EMBEDDED SYSTEMS',
credit: 100,
num_grd: 83
},
{
title: 'MOBILE COMPUTING',
credit: 100,
num_grd: 51
},
{
title: 'DISTRIBUTED SYSTEMS LAB',
credit: 75,
num_grd: 69
},
{
title: 'EMBEDDED SYSTEMS LAB',
credit: 75,
num_grd: 61
},
{
title: 'PROJECT SEMINAR',
credit: 25,
num_grd: 10
},
{
title: 'DATA MINING',
credit: 100,
num_grd: 69,
},
{
title: 'SOFTWARE QUALITY & TESTING',
credit: 100,
num_grd: 80,
},
{
title: 'DISASTER MITIGATION & MANAGEMENT',
credit: 100,
num_grd: 64,
},
{
title: 'DATA MINING LAB',
credit: 75,
num_grd: 60
},
{
title: 'PROJECT',
credit: 50,
num_grd: 50
},
{
title: 'SEMINAR',
credit: 25,
num_grd: 10
},
]
// console.log(JSON.stringify(data));
// Example Run after the following the steps above:
prefillSubjectsAndGrades(`[{"title":"ENGLISH","credit":100,"num_grd":66},{"title":"MATHEMATICS - I","credit":100,"num_grd":56},{"title":"MATHEMATICS - II","credit":100,"num_grd":62},{"title":"ENGINEERING PHYSICS","credit":100,"num_grd":50},{"title":"PHYSICS LAB","credit":75,"num_grd":68},{"title":"ENGINEERING CHEMISTRY","credit":100,"num_grd":63},{"title":"CHEMISTRY LAB","credit":75,"num_grd":57},{"title":"ENGINEERING GRAPHICS","credit":150,"num_grd":89},{"title":"WORKSHOP PRACTICE","credit":100,"num_grd":67},{"title":"ENGINEERING MECHANICS","credit":100,"num_grd":46},{"title":"PROGRAMMING IN C & C++","credit":100,"num_grd":78},{"title":"PROGRAMMING LAB","credit":75,"num_grd":74},{"title":"ENGLISH LANGUAGE LAB","credit":75,"num_grd":69},{"title":"MATHEMATICS - III","credit":100,"num_grd":63},{"title":"DATA STRUCTURES USING C++","credit":100,"num_grd":73},{"title":"DISCRETE STRUCTURES","credit":100,"num_grd":62},{"title":"LOGIC & SWITCHING THEORY","credit":100,"num_grd":59},{"title":"COMPUTER ARCHITECTURE","credit":100,"num_grd":78},{"title":"BASIC ELECTRONICS","credit":100,"num_grd":68},{"title":"DATA STRUCTURES LAB USING C++","credit":75,"num_grd":70},{"title":"BASIC ELECTRONICS LAB","credit":75,"num_grd":60},{"title":"MATHEMATICS - IV","credit":100,"num_grd":44},{"title":"OOP USING JAVA","credit":100,"num_grd":76},{"title":"MICROPROCESSORS & INTERFACING","credit":100,"num_grd":53},{"title":"DATA COMMUNICATIONS","credit":100,"num_grd":49},{"title":"ELECTRICAL CIRCUITS & MACHINES","credit":100,"num_grd":42},{"title":"ENVIRONMENTAL STUDIES","credit":100,"num_grd":73},{"title":"JAVA PROGRAMMING LAB","credit":75,"num_grd":68},{"title":"MICROPROCESSOR LAB","credit":75,"num_grd":53},{"title":"DATABASE MANAGEMENT SYSTEMS","credit":100,"num_grd":72},{"title":"OPERATING SYSTEMS","credit":100,"num_grd":61},{"title":"AUTOMATA, LANGUAGES AND COMPUTATION","credit":100,"num_grd":72},{"title":"SOFTWARE ENGINEERING","credit":100,"num_grd":55},{"title":"MANAGERIAL ECONOMICS & ACCOUNTANCY","credit":100,"num_grd":67},{"title":"DESIGN & ANALYSIS OF ALGORITHMS","credit":100,"num_grd":66},{"title":"DATABASE MANAGEMENT SYSTEM LAB","credit":75,"num_grd":69},{"title":"OPERATING SYSTEMS LAB","credit":100,"num_grd":66},{"title":"MINI PROJECT","credit":25,"num_grd":22},{"title":"WEB PROGRAMMING & SERVICES","credit":100,"num_grd":65},{"title":"COMPILER CONSTRUCTION","credit":100,"num_grd":75},{"title":"PRINCIPLES OF PROGRAMMING LANGUAGES","credit":100,"num_grd":58},{"title":"OBJECT ORIENTED SYSTEMS DEVELOPMENT","credit":100,"num_grd":78},{"title":"COMPUTER NETWORKS","credit":100,"num_grd":49},{"title":"WPS & CN LAB","credit":75,"num_grd":56},{"title":"OOSD LAB","credit":75,"num_grd":51},{"title":"COMPILER CONSTRUCTION LAB","credit":100,"num_grd":51},{"title":"MINI PROJECT","credit":25,"num_grd":10},{"title":"DISTRIBUTED SYSTEMS","credit":100,"num_grd":71},{"title":"ARTIFICIAL INTELLIGENCE","credit":100,"num_grd":70},{"title":"INFORMATION SECURITY","credit":100,"num_grd":64},{"title":"PRINCIPLES & APPLICATIONS OF EMBEDDED SYSTEMS","credit":100,"num_grd":83},{"title":"MOBILE COMPUTING","credit":100,"num_grd":51},{"title":"DISTRIBUTED SYSTEMS LAB","credit":75,"num_grd":69},{"title":"EMBEDDED SYSTEMS LAB","credit":75,"num_grd":61},{"title":"PROJECT SEMINAR","credit":25,"num_grd":10},{"title":"DATA MINING","credit":100,"num_grd":69},{"title":"SOFTWARE QUALITY & TESTING","credit":100,"num_grd":80},{"title":"DISASTER MITIGATION & MANAGEMENT","credit":100,"num_grd":64},{"title":"DATA MINING LAB","credit":75,"num_grd":60},{"title":"PROJECT","credit":50,"num_grd":50},{"title":"SEMINAR","credit":25,"num_grd":10}]`);
// above line is same as: `prefillSubjectsAndGrades(JSON.stringify(data))`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment