I've been working on a bookmarklet that performs some logic and then redirects the user to a different page. I'm running into an issue where, after the redirect, Chrome is replacing the icon of the bookmark with the favicon from the target of the redirection.
I'm trying to preserve the original icon on the bookmarklet and so am wondering if there is any way that I can prevent this behaviour?
As an example. Bookmarklet starts off looking like this:
If the bookmarklet were to redirect the user to Stack Overflow then on clicking the bookmarklet icon is replaced:
I've tried a couple of approaches to perform the redirect, all of which have this behaviour:
Bookmark is a link to a server-side page that performs the redirect by returning a 302 with a
Location
headerBookmark is a link to a server-side page that executes JavaScript on page load that performs the redirect using
window.location.replace
So far I have a couple of other approaches which avoid this particular issue, but have other downsides of their own:
Bookmark is a link to a server-side page that executes JavaScript on page load to perform the redirect using
window.location.assign
- if user click the back button they are taken to my page which then redirects them again, and can result in the user getting stuck in a loopBookmark is a
javascript:
link which makes afetch
request to perform logic in the background and then goes to the target page usingwindow.location
- this works OK, except for on a new blank tab where JS bookmarks are no longer allowed.