Skip to content

Instantly share code, notes, and snippets.

@iwconfig
Last active October 15, 2018 19:43
Show Gist options
  • Select an option

  • Save iwconfig/91cc0f12d6a5835aea54cc48d1e53123 to your computer and use it in GitHub Desktop.

Select an option

Save iwconfig/91cc0f12d6a5835aea54cc48d1e53123 to your computer and use it in GitHub Desktop.
codeacademy.com enhancements. Currently changes the text opacity of unfinished tasks and also adds additional keyboard shortcuts (Alt-LeftArrow and Alt-RightArrow) for Back and Next.
// ==UserScript==
// @name codeacademy.com enhancements
// @namespace Leonard Högström
// @match https://www.codecademy.com/courses/*
// @grant none
// ==/UserScript==
// Change the text opacity of unchecked tasks for better readability
// so you can do all of them at once instead of having to run the code with every completed task.
[].filter.call(document.querySelectorAll('.fcn-checkpoint--disabled .fcn-checkpoint__body'),item => item)
.forEach(item => item.style.opacity = 1);
// Add keyboard shortcuts to the 'Back' and 'Next' buttons for easier use with non-english keyboards.
// Alt-LeftArrow and Alt-RightArrow
window.addEventListener("keydown", function(e) {
if (e.ctrlKey) {
console.log(e.altKey)
if (e.which === 39) {
console.log('next')
var _ = document.querySelector('#discovery-next')
_.disabled || _.click();
}
if (e.which === 37) {
console.log('back')
var _ = document.querySelector('.fcn-nav-wrapper > div > button')
_.innerText === 'Back' && _.click();
}
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment