搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

Using an autoconfig file to create bookmarks

  • 3 回覆
  • 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 於 修改