-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleaned up content script and separated out scraping into separate fi…
…le for maintainability
- Loading branch information
Showing
3 changed files
with
110 additions
and
59 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,30 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"commonjs": true, | ||
"es6": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
2 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"semi": [ | ||
"error", | ||
"never" | ||
] | ||
} | ||
}; |
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
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,34 @@ | ||
// DOM searching functions go here. | ||
|
||
export function onDetailedSchedulePage() { | ||
return (document.querySelector('div.pagetitlediv h2').textContent === 'View detailed timetable') | ||
} | ||
|
||
export function getSemester() { | ||
return document.querySelector('div.staticheaders').childNodes[2].textContent.split(': ')[1] | ||
} | ||
|
||
export function getClassSections() { | ||
return document.querySelectorAll('div#P_CrseSchdDetl > table.datadisplaytable') | ||
} | ||
|
||
export function getScheduledMeetingTimes(classSection) { | ||
let scheduledMeetingTimesTable = classSection.querySelector('table.datadisplaytable.tablesorter > tbody > tbody') | ||
return [...scheduledMeetingTimesTable.rows] | ||
} | ||
|
||
export function getClassSectionTitle(classSection) { | ||
return classSection.querySelector('caption').textContent | ||
} | ||
|
||
const headerLinks = document.querySelector('span.pageheaderlinks') | ||
export function insertExportLink(exportLink) { | ||
|
||
// During dev reloading extension caused multiple buttons to be added | ||
let oldLink = headerLinks.querySelector('#uvical_export') | ||
if (oldLink) { | ||
headerLinks.removeChild(oldLink) | ||
} | ||
|
||
headerLinks.insertBefore(exportLink, headerLinks.firstChild) | ||
} |