Adding shortcut keys to Safari on iPadOS with Userscripts, to open new tabs with your favorite website.

LEICA M-P (Typ 240) + Summicron 50mm f/2.0 Leitz

There's still no way to set any webpages as a homepage of Safari when opening new tabs or new windows on iPadOS. Maybe that'll never change in the future as well. So, I tried to consider if there's some ways to fix is.

My idea.

LEICA Q + Summilux 28mm f/1.7 (28mm)

This solution doesn't work when tapping a new tab button or using original shortcut key to open new tab "Command+T". But when using hardware keyboard like MagicKeyboard from Apple, this just works with no problem.

First of all, we need to install an app extension of Safari called "Userscripts". This extension allows us JavaScript written by ourselves when opening webpages. It has some more features, but I don't touch them here. If you want to know some more about it, please google it by yourself.

Userscript needs to be installed both of Safari on iPad and Safari on Mac. And when you're ready, try creating new JavaScript file on Userscripts on Mac and paste the code below to the JavaScript file. One more thing, give a permission to that JavaScript file to run on all of the websites.

addEventListener("keydown", (event) => {
if ( event.key == 'z' && event.ctrlKey == true ) {
window.open("URL OF YOUR FAVORITE WEBPAGE")
}
})

Then we get to be able to open a webpage set on the JavaScript file with a new tab, using a shortcut key "Ctrl+Z" defined on the same JavaScript file. It seems to be unable to be overridden and not work with shortcut keys defined originally like "Command+T", but we can define as shortcut keys except them. By the way, the JavaScript file runs after webpages get loaded, so it doesn't work during loading.

If you get interested in this, try it. So see you then.