Skip to content

Instantly share code, notes, and snippets.

@tidusx18
Created December 10, 2018 19:33
Show Gist options
  • Save tidusx18/4f44f9530171dde33c1bd493f14c13cc to your computer and use it in GitHub Desktop.
Save tidusx18/4f44f9530171dde33c1bd493f14c13cc to your computer and use it in GitHub Desktop.
User needs to click into syllabus calendar to enable targeted selector.
function replaceCreatorProDates() {
let regex = />Module available from.+</igm;
// let regex = />Module available from.+<\/p>|<p>.+Module available from.+<\/p>/igm;
let calendarDates = document.querySelectorAll('.generic_table.cke_show_border tbody tr > td:first-child');
let newDates = [
'>Module available from Monday, Jan 7 at 5:00 AM - Tuesday, Jan 15 at 11:55 PM<',
'>Module available from Monday, Jan 14 at 5:00 AM - Tuesday, Jan 22 at 11:55 PM<',
'>Module available from Monday, Jan 21 at 5:00 AM - Tuesday, Jan 29 at 11:55 PM<',
'>Module available from Monday, Jan 28 at 5:00 AM - Tuesday, Feb Feb 5 at 11:55 PM<',
'>Module available from Monday, Feb 4 at 5:00 AM - Tuesday, Feb 12 at 11:55 PM<',
'>Module available from Monday, Feb 11 at 5:00 AM - Tuesday, Feb 19 at 11:55 PM<',
'>Module available from Monday, Feb 18 at 5:00 AM - Tuesday, Feb 26 at 11:55 PM<',
'>Module available from Monday, Feb 25 at 5:00 AM - Tuesday, Mar 5 at 11:55 PM<',
'>Module available from Monday, Mar 4 at 5:00 AM - Tuesday, Mar 19 at 11:55 PM<',
'>Module available from Monday, Mar 18 at 5:00 AM - Tuesday, Mar 26 at 11:55 PM<',
'>Module available from Monday, Mar 25 at 5:00 AM - Tuesday, Apr 2 at 11:55 PM<',
'>Module available from Monday, Apr 1 at 5:00 AM - Tuesday, Apr 9 at 11:55 PM<',
'>Module available from Monday, Apr 8 at 5:00 AM - Tuesday, Apr 16 at 11:55 PM<',
'>Module available from Monday, Apr 15 at 5:00 AM - Sunday, Apr 21 at 11:55 PM<',
'>Module available from Monday, Apr 22 at 5:00 AM - Friday, Apr 26 at 11:55 PM<'
];
if(calendarDates.length !== 15) {
alert('There are not 15 weeks/modules.');
return;
}
calendarDates.forEach( (date, index) => {
updateDate(date, regex, newDates[index]);
console.log(newDates[index])
});
}
function updateDate(target, regex, newDate) {
let updatedContent = target.innerHTML.replace(regex, newDate);
target.innerHTML = updatedContent;
}
replaceCreatorProDates();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment