-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e4417b4
Showing
8 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
![Chrome extension in action](showcase.gif?raw=true "SGA extension in action") | ||
|
||
Use this extension when deciding subjects for next semester. | ||
|
||
Don't waste your time looking up every subject by its code to find out its schedules. | ||
|
||
## Installation | ||
1. Clone the repo | ||
2. [Load extension](https://developer.chrome.com/extensions/getstarted#unpacked) | ||
|
||
## Usage | ||
1. Go to SGA | ||
2. Click on Legajo > Datos del Alumno > Analítico de notas | ||
3. Refresh page and watch the shortcuts appear | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
let subjectCode = null | ||
let nextStep = null; | ||
|
||
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) { | ||
switch(request.type) { | ||
case 'storeSubjectCode': | ||
subjectCode = request.subjectCode | ||
nextStep = 'searchSubject' | ||
sendResponse({}) | ||
break | ||
case 'hasSearchedPage': | ||
nextStep = 'clickResults' | ||
sendResponse({}) | ||
break | ||
case 'hasFoundSubjectPage': | ||
nextStep = 'showSchedules' | ||
sendResponse({}) | ||
break | ||
case 'requestAction': | ||
sendResponse({ nextStep: nextStep, subjectCode: subjectCode }) | ||
break | ||
case 'stop': | ||
subjectCode = null | ||
nextStep = null | ||
break | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const send = (request, callback = (response => {})) => ( | ||
chrome.extension.sendMessage(request, callback) | ||
) | ||
|
||
const getLink = (text) => ( | ||
Array.from(document.querySelectorAll('a')).filter(a => a.innerText === text)[0] | ||
) | ||
|
||
const createShortcutLinks = () => { | ||
Array.from(document.querySelectorAll('.subjectBackground')).forEach(e => { | ||
const cell = e.querySelector('td') | ||
const subjectCode = cell.querySelector('span.bold').innerText.match(/[0-9]{2}\.[0-9]{2}/)[0] | ||
const link = document.createElement('a') | ||
Array.from(cell.childNodes).forEach(child => link.appendChild(child)) | ||
link.href = '#' | ||
link.addEventListener("click", () => openSearchPage(subjectCode), false); | ||
|
||
cell.innerHTML = null | ||
cell.appendChild(link) | ||
}) | ||
} | ||
|
||
const openSearchPage = (subjectCode) => { | ||
send({ type: 'storeSubjectCode', subjectCode: subjectCode }) | ||
window.location = getLink('Cursos').href | ||
} | ||
|
||
const semesterFilterValue = () => { | ||
const month = (new Date()).getMonth() + 1 | ||
if (month > 5 && month < 11) { | ||
return 1 // You are looking for second semester info | ||
} else { | ||
return 0 // You are looking for first semester info | ||
} | ||
} | ||
|
||
const searchSubject = (subjectCode) => { | ||
// Subject code filter | ||
document.querySelector('.filters-tr .filter-td input').value = subjectCode | ||
|
||
// Semester filter | ||
Array.from(document.querySelectorAll('.filters-tr .filter-td select')).filter(s => { | ||
const options = Array.from(s.querySelectorAll('option')).map(o => o.innerText) | ||
return options.includes('Primer Cuat.', 'Segundo Cuat.') | ||
})[0].value = semesterFilterValue() | ||
|
||
document.querySelector('a[title=Filtrar]').click() | ||
send({ type: 'hasSearchedPage' }) | ||
} | ||
|
||
const clickResults = (subjectCode) => { | ||
send({ type: 'hasFoundSubjectPage' }) | ||
document.querySelector('tr img[title="Ver Detalles"]').click() | ||
} | ||
|
||
const showSchedules = () => { | ||
send({ type: 'stop' }) | ||
getLink('Comisiones').click() | ||
} | ||
|
||
send({ type: 'requestAction' }, (response) => { | ||
switch (response.nextStep) { | ||
case 'searchSubject': | ||
searchSubject(response.subjectCode) | ||
break; | ||
case 'clickResults': | ||
clickResults(response.subjectCode) | ||
break; | ||
case 'showSchedules': | ||
showSchedules() | ||
break | ||
} | ||
}) | ||
|
||
createShortcutLinks() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const searchPage = Array.from(document.querySelectorAll('a')).filter(a => a.innerText === 'Cursos')[0] | ||
|
||
// Every link | ||
|
||
Array.from(document.querySelectorAll('.subjectBackground')).forEach(e => { | ||
const cell = e.querySelector('td'); | ||
const subjectCode = cell.querySelector('span.bold').innerText.match(/[0-9]{2}\.[0-9]{2}/)[0]; | ||
cell.innerHTML = `<a href=foo'>${cell.innerHTML}</a>` | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "SGA - Subject Schedule Shortcut", | ||
"description": "This extension create shortcuts to subject schedules", | ||
"version": "1.0.0", | ||
"minimum_chrome_version": "47", | ||
"page_action": { | ||
"default_icon": { | ||
"19": "icon_19.png", | ||
"38": "icon_38.png" | ||
} | ||
}, | ||
"permissions": [ | ||
"activeTab" | ||
], | ||
"background": { | ||
"scripts": ["background.js"] | ||
}, | ||
"content_scripts": [{ | ||
"matches": [ | ||
"https://sga.itba.edu.ar/*" | ||
], | ||
"js": ["contentscript.js"], | ||
"run_at": "document_idle", | ||
"all_frames": false | ||
}] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.