Skip to content

Instantly share code, notes, and snippets.

@Synvox
Last active April 21, 2020 23:47
Show Gist options
  • Save Synvox/16c42bf1170e18af5b1f3a401ba5fcbb to your computer and use it in GitHub Desktop.
Save Synvox/16c42bf1170e18af5b1f3a401ba5fcbb to your computer and use it in GitHub Desktop.
Fix I-Know's mega course problem

I-Know's out of space issue for some BYU-Idaho courses

This is a hacky script to fix an issue several students at BYU-Idaho are having with I-Know. I-Know has a space limit of 5mb and there are a couple courses at BYU-Idaho that are exceeding that limit. There is a fix released to the Chrome Webstore but it may take weeks for it to be released to every student.

The issue is caused by the extension running out of space before saving course information. There is a way to disable courses in the settings of I-Know but because I-Know runs out of space before saving that list, students are not able to fix the issue themselves.

This script disables courses that ended before March 1st 2020, which is generally what students end up doing anyway.

1. Start!

Make sure you are signed into Canvas then go to this url in Chrome:

chrome-extension://oobphcndhljfbmllppplinbdagpnfbjp/index.html

2. Then open up the developer console

You can do this by hitting F12 on windows or Option+Command+J on Mac. You can also right click anywhere on the page and click inspect element.

A scary window will appear. Do not worry, you are a professional. Make sure you are in the console tab of that window.

3. Paste this code there and hit enter

// clear out old information stored by the chrome extension for previous courses.
for (let key in localStorage)
  if (key.startsWith("user")) delete localStorage[key];

// load the list of courses from I-Learn
json = await fetch(
  "https://byui.instructure.com/api/v1/courses?enrollment_type=student&per_page=100",
  { headers: { "content-type": "application/json; charset=utf-8" } }
).then((x) => x.text());
courses = JSON.parse(json.replace("while(1);", ""));

// find courses that ended before march 1st 2020
hiddenEnrollments = courses
  .filter((course) => Date.parse(course.end_at) < Date.parse("March 1 2020"))
  .map((course) => `https://byui.instructure.com|${course.id}`);

// tell I-Know to not load these courses anymore
localStorage.hiddenEnrollments = JSON.stringify(hiddenEnrollments);

console.log('It worked 🎉');

4. Close the scary window and refresh I-Know

I-Know should be able to load your current courses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment