I am trying to make a bookmarklet that will log me into my canvas and goes to a zoom page after it has loaded
This is my code:
This will log in the user into canvas | V javascript:void(location.href='https://pccsk12.instructure.com/login/saml');
setTimeout(()=>{void(location.href='https://pccsk12.instructure.com/courses/9645/external_tools/184');},10000); ^ | This will switch to the zoom page after everything has loaded
But it doesn't work. It logs in but doesn't redirect after 10 seconds. What is wrong with my code?
When you switch the page the first time with location.href
, it navigates to the new page and unloads all the currently running Javascript, including the timeout. You could try opening the login page in a new tab with window.open
, so it doesn't overwrite the current tab. It would look something like this:
javascript:(function(){
var login = window.open('https://pccsk12.instructure.com/login/saml');
setTimeout(() => {login.location.href = 'https://pccsk12.instructure.com/courses/9645/external_tools/184';}, 10000);
})();