Last active
February 16, 2022 17:27
-
-
Save rullinoiz/be6f00336a9fd605274a77854239916d to your computer and use it in GitHub Desktop.
insert calculatorsoup into all positive physics assignments
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
// ==UserScript== | |
// @name Positive Physics CalculatorSoup embed | |
// @version 1.1 | |
// @description Embeds CalculatorSoup into Positive Physics | |
// @author ollinruiz | |
// @match https://www.positivephysics.org/positiveskill* | |
// @grant none | |
// @run-at document-end | |
// @require https://code.jquery.com/jquery-3.6.0.js | |
// @require https://code.jquery.com/ui/1.13.1/jquery-ui.js | |
// ==/UserScript== | |
var dragBox = document.createElement("div"); | |
var iframe = document.createElement("iframe"); | |
iframe.style.width = "100%"; | |
iframe.style.height = "300px" | |
iframe.src = "https://www.calculatorsoup.com/calculators/physics/"; | |
dragBox.id = "frame"; | |
dragBox.title = "Calculator Soup"; | |
dragBox.style.display = "none" | |
//https://stackoverflow.com/questions/42272593/draggable-iframe-registers-click-instead-of-drag | |
/* | |
$(".draggable").draggable({ | |
iframeFix: true | |
}); | |
$('.btn-drag, .btn-play').click(function(){ | |
if($(this).hasClass('btn-drag')){ | |
$('.btn-drag').addClass('active'); | |
$('.btn-play').removeClass('active'); | |
$('#frame').css('pointer-events','none'); | |
} | |
else{ | |
$('.btn-drag').removeClass('active'); | |
$('.btn-play').addClass('active'); | |
$('#frame').css('pointer-events','auto'); | |
} | |
}); | |
*/ | |
//var dialog = $("#frame").dialog(); | |
document.addEventListener("keydown", function (e) { | |
if(!e.shiftKey){ | |
return false; | |
} | |
if(document.getElementById("frame").style.display === 'none'){ | |
//$('.btn-drag, .btn-play').toggleClass('active'); | |
document.getElementById("frame").style.display = 'block'; | |
} | |
else{ | |
//$('.btn-play, .btn-drag').toggleClass('active'); | |
document.getElementById("frame").style.display = 'none'; | |
} | |
}); | |
dragBox.appendChild(iframe); | |
$("#pageContent").append(dragBox); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1.1: moved the iframe into the problem tag and added a key (shift) to open and hide it