rasenkantenstein
rasenkantenstein

Reputation: 367

Replace bookmark URL JavaScript

Scenario: A reporting tool run in our company has been upgraded to a newer version. It is being accessed by a URL in a browser: www.company.de/programm/v8/client/ The users were able to save browser bookmarks. I.e.: www.company.de/programm/v8/client/report1

The updated URL has changed (www.company.de/programm/new/v10/client/), thus letting all saved user-bookmarks resolve into nothingness.

My question: Is there a snippet for JS that either updates the URL string from "v8/" to "new/v10/" or at least scans to existing bookmarks inside the users bookmarks and adds new ones with a new URL (leaving the previous ones untouched)?

Upvotes: 0

Views: 1761

Answers (2)

Daniel Maiochi
Daniel Maiochi

Reputation: 627

You actually can't change your bookmarks using javascript. The easiest way to do that is to change the bookmark file manually

The Chrome one for example is located here:

C:\Users\USERNAME\AppData\Local\Google\Chrome\User Data\Default\Bookmarks

Upvotes: 2

Thusitha
Thusitha

Reputation: 3511

No. You can not access the browser bookmarks though a webpage or in a JavaScript file within a web page.

But,

  1. You can create a browser extension with the extension api which will scan all the bookmarks in a browser and give access to update those with new URLs. But this will need to install a custom browser extension in the user's browser. Browser extension API supports Chrome, Firefox and Safari, Edge with some polyfills. Sorry about the IE support. Writing extensions for IE is a nightmare.

You can read more about the extension api in
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/bookmarks

  1. Simply redirect you old URL to the new URL. Which means redirecting www.company.de/programm/v8/client/report1 --> www.company.de/programm/new/v10/client/ through the same web server. Implementation is varying with the server you use. Just write a path matching rule.

Upvotes: 2

Related Questions