Safari extension variable storage

Discussion in 'Mac Programming' started by sammy.d, Nov 11, 2014.

  1. sammy.d macrumors regular

    Joined:
    Jun 18, 2010
    #1
    Hi, I am attempting to create my first Safari extension and a bit overwhelmed and confused. I want my extension to show a menu when the toolbar icon is pressed. Initially this menu will only have a "save" option, which when pressed will store the URLs of all of the tabs in that active window. The idea of this is that when you are researching a topic and have a window open with several tabs and you know that you wont be coming back to them for a few days, this extension will save all of those tabs and you can then restore that entire window (with all of its tabs) in a few days time.

    Trouble is, I don't know how to store the information. I would use the browserWindow.tabs array but I don't know where to store it. Do I need to use HTML local storage? Or do I allocate storage in a script in the global file? Once this information is stored, I will make it add an entry to the toolbar menu. Whent his entry is selected, the window and tabs will be restored.

    Any tips would be appreciated.
     
  2. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #2
    Why don't you just create a bookmark, it does exactly this.
     
  3. sammy.d thread starter macrumors regular

    Joined:
    Jun 18, 2010
    #3
    I am using this in a situation where I have upwards of six tabs open in a window and want to save all of those tabs. If I use bookmarks I will I have to bookmark each of the tabs and then restore the tabs individually. I am trying to make something that does them all at once. Unless you can suggest a way to achieve that using bookmarks...?
     
  4. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #4
    Safari has bookmarks folders.

    [​IMG]
     
  5. sammy.d, Nov 12, 2014
    Last edited: Nov 12, 2014

    sammy.d thread starter macrumors regular

    Joined:
    Jun 18, 2010
    #5
    Yes, I am aware of that option, however when it comes to restoring those tabs I am going to have to open a new window then open 11 new tabs within it and then in each of those tabs select the bookmark for it. I want a way of pressing one button and automatically loading those 11 tabs with their correct page.

    I found an option to do this by going to the bookmarks menu >> favourites >> the desired folder >> then there is an open in tabs option. This will suffice I suppose but I was hoping for something like being able to right click on the bookmarks folder from the new window view where it shows the bookmarks icons (in Yosemite) and having an open in tabs option there. However nothing comes up with a right click there. This method is also a bit annoying if I want to update the tabs in the folder, i.e. if I have saved a set of tabs and then restore them later, and while I am working on them I open a couple of new tabs, I will either have to add the new tabs individually and manually, or go to manage bookmarks and delete the bookmarks folder so i can save a new one. A bit of fiddling there...
     
  6. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #6
    I understood the purpose of this from your first question, point is, I use this myself all, the, time. And unless this has changed in Yosemite, then restoring all those tabs is a one-click operation. What you need, is to use the browser bookmarks bar, not the menu. Then removing the folder is also only a question of dragging it off the bookmarks bar.
     
  7. sammy.d thread starter macrumors regular

    Joined:
    Jun 18, 2010
    #7
    Ahhhh I had assumed that Yosemite had dumped the bookmarks bar because it is hidden by default. I only just thought to try and reactivate it. Found it and it works pretty well for what I want. Saves me a lot of time trying to figure out how to make the extension!

    Thanks :)
     

Share This Page