Turning Bookmarklets into Shortcuts

I’m trying to figure out how to convert some of my bookmarklets to Shortcuts. For example, this one converts a web page to an ePub. They provide code for a bookseller on their website, but I can’t figure out how to edit the code to make it run as a “Run JavaScript on Web Page” action in Shortcuts. Any ideas?

1 Like

Try this.

I set the Shortcut to be usable from the share sheet for Safari Web Pages, put the bookmarklet script into the JavaScript action,replaced some of the percent encoding to have spaces in the JavaScript and added the required completion function call at the end.


Here’s the JavaScript, but reformatted for easier reading.

javascript: (function()
		var d = document,
			w = window;
		if (!d.body || d.body.innerHTML == '') throw (0);
		var s = d.createElement('link'),
			h = d.getElementsByTagName('head')[0],
			i = d.createElement('div'),
			j = d.createElement('script');
		s.rel = 'stylesheet';
		s.href = '//dotepub.com/s/dotEPUB-favlet.css';
		s.type = 'text/css';
		s.media = 'screen';
		i.setAttribute('id', 'dotepub');
		i.innerHTML = '<div id=%22status%22><p>Conversion in progress...</p></div>';
		j.type = 'text/javascript';
		j.charset = 'utf-8';
		j.src = '//dotepub.com/j/dotepub.js?v=1.2&s=0&t=epub&g=en';
	catch (e)
		w.alert('The page has no content or it is not fully loaded. Please, wait till the page is loaded.');


In my quick test it did produce an ePub that contained at least a sub set of page content, so based on that I’m assuming it is working as expected.

Hope that helps.

Thank you so very much! I was trying to figure out how to clean up the code, and this did it perfectly. Much appreciated!

Hi Sylumer,

Sorry to resurrecting this thread, I am trying to make another bookmarklet from PrintFriendly to iOS shortcut, but I can’t get it to work.

bookmarklet in following page


my modified shortcut javascript version as follow:



I also tried putting my code into your Safari Page to ePub shortcut, but still not working as expected. Any suggestion?

1 Like

I don’t know why it doesn’t work. There’s a lot that goes on in these libraries and I honestly don’t have the time to try and work out what it is doing in printfriendly.js and beyond (it isn’t trivial). Sometimes they work by dropping them into a Shortcut, sometimes they don’t. The reasons can vary.

But it does still work from a bookmark on iOS (and that’s from testing on an iPhone, not even an enhanced iPad Safari) - I would suggest that you utilise that approach for now.

Hi Sylumer,

Thanks for replying, I will use the bookmarklet instead.

1 Like