Random Home Page on Safari

Hi everybody. I've been looking for an extension on Safari that allows you to program more than one home page. Then have it display a random selection of home pages (from a custom url list you create).

For example, if I open a new window (or click on home icon) it will open Wall Street Journal home page, later on when I open Safari again with a new window or tab it will open yahoo.com... then later... LA Times.... and if I refresh or click ohome page it gives me reddit... then twitter and so on.

I would ultimately just create a list of like 6 urls or so, but the idea is you get different social media or news feeds thorough out the day as you carry on with work.

Is there a way to do this with KM... I feel like there is and I just have to figure it out I guess. Unless someone knows exactly what to do and thus save me a lot of experimenting (I'm not a programmer). Thanks all!

If you always use Command-N to open a new page, then you can just have that trigger a macro which uses the New Safari Window action with a randomly selected URL.

1 Like

So, then the question is... how do you create a random action?

Try this macro for size:
Test Random Homepage.kmmacros (5.1 KB)

Click to see macro

Change the list of URLs to suit yourself.

You must place this macro in a macro group that is active only for Safari, like this:
KM 0 2022-10-11_18-21-19

The macro runs (provided you've enabled it first) when you type N while in Safari.

You can change the hotkey trigger to whatever you prefer...

1 Like

Use a Switch or Case action with a RAND function, and each case entry can be a different home page.

1 Like

Another alternative to the above suggestions is to use a Focused Window trigger in a Safari-only macro group with a condition that checks to see if the frontmost tab or window is blank or the default Safari start page before loading a random site. This way, you can open a new tab or window or click the Home button, and the macro will still work regardless of whether you use keyboard shortcuts, the mouse, or menu commands to do so.

As for choosing a site randomly, I can think of a couple of methods in addition to the ones suggested above. One uses a KM variable array:

Random Home Page - Array.kmmacros (4.4 KB)

Macro Image

And the other the Shuffle Lines filter:

Random Home Page - Filter.kmmacros (4.8 KB)

Macro Image

Of course, both of these and the above suggestions should work identically in practice, trigger aside, so choosing which one to use is just a matter of personal preference.

1 Like