Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Претражи подршку

Избегните преваре подршке. Никада од вас нећемо тражити да зовете или шаљете поруке на број или да делите личне податке. Пријавите сумњиве радње преко „Пријавите злоупотребу” опције.

Learn More

Using an autoconfig file to create bookmarks

  • 3 одговорa
  • 1 има овај проблем
  • 1 преглед
  • Последњи одговор послао eddythorn

more options

I'm using an example provided by Mike Kaply to modify my autoconfig file to add bookmarks to users profiles. However, every time I launch FF, instead of the bookmarks being overwritten, I get an extra set. So, after 5 re-launches, I have 5 sets of the bookmarks I'm adding. Is there a way to prevent this? Here is the code I'm using: //Add bookmarks Components.utils.import("resource://gre/modules/Services.jsm"); var uri = Services.io.newURI("http://mike.kaply.com", null, null); var navBook = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Components.interfaces.nsINavBookmarksService); //create new Folder var FolderId = navBook.createFolder(navBook.bookmarksMenuFolder, "New Folder", 0); //add bookmark to newly created folder navBook.insertBookmark(SCCCFolderId, uri, -1, "Mike's Blog");

I'm using an example provided by Mike Kaply to modify my autoconfig file to add bookmarks to users profiles. However, every time I launch FF, instead of the bookmarks being overwritten, I get an extra set. So, after 5 re-launches, I have 5 sets of the bookmarks I'm adding. Is there a way to prevent this? Here is the code I'm using: //Add bookmarks Components.utils.import("resource://gre/modules/Services.jsm"); var uri = Services.io.newURI("http://mike.kaply.com", null, null); var navBook = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Components.interfaces.nsINavBookmarksService); //create new Folder var FolderId = navBook.createFolder(navBook.bookmarksMenuFolder, "New Folder", 0); //add bookmark to newly created folder navBook.insertBookmark(SCCCFolderId, uri, -1, "Mike's Blog");

Измењено од стране eddythorn

Изабрано решење

In the end, I had to write code using a for loop with an if/then statement to look for an existing bookmark. Obviously it's a little more complicated than this. It wasn't easy, but I'm able to do what I need to.

Прочитајте овај одговор са објашњењем 👍 0

Сви одговори (3)

more options
more options

My understanding is that the distribution file is only implemented for new profiles - that it isn't read for existing users. Is this true?

more options

Одабрано решење

In the end, I had to write code using a for loop with an if/then statement to look for an existing bookmark. Obviously it's a little more complicated than this. It wasn't easy, but I'm able to do what I need to.

Измењено од стране eddythorn