Skip to content

Instantly share code, notes, and snippets.

@jlewin
Created December 18, 2023 23:29
Show Gist options
  • Save jlewin/719cc561dd19fa09e808f6f55137d9c9 to your computer and use it in GitHub Desktop.
Save jlewin/719cc561dd19fa09e808f6f55137d9c9 to your computer and use it in GitHub Desktop.
Quizlet Print Revisions
// ==UserScript==
// @name QuizletPrint
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Cleanup for quizlet print
// @author John Lewin
// @match https://quizlet.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function findFirstParentWithClass(element, className) {
while (element && element !== document) {
element = element.parentElement;
if (element.classList.contains(className)) {
return element;
}
}
return null; // Return null if no parent with the specified class is found
}
// Function to find the H3 element
function removeNoise() {
// Remove header
document.querySelector('.HeaderLayout header').remove();
// Remove footer
document.querySelector('.s1dq4ceh').remove();
// Remove stupid mid-page upsell of non-related content
for (let h3 of document.getElementsByTagName('h3')) {
if (h3.textContent.includes('Students also viewed'))
{
findFirstParentWithClass(h3, 'SetPage-content').remove();
break;
}
}
}
// Wait for the page to fully load
window.addEventListener('load', removeNoise);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment