Skip to content

Commit

Permalink
Use chrome.tabs.
Browse files Browse the repository at this point in the history
Fixes #1. Kinda.  See discussion there.
  • Loading branch information
Stephen Blott committed May 14, 2015
1 parent 643ef8c commit b2d9204
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"manifest_version": 2,
"name": "New tab URL",
"version": "1.0.1",
"version": "1.0.2",
"description": "Redirect new tabs to a given URL.",
"options_page": "options.html",
"chrome_url_overrides": { "newtab": "redirect.html" },
"permissions": [ "storage" ]
"permissions": [ "storage", "tabs" ]
}
6 changes: 5 additions & 1 deletion redirect.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ documentReady = (func) ->
if document.readyState == "loading" then window.addEventListener "DOMContentLoaded", func else func()

chrome.storage.sync.get "url", (items) ->
documentReady -> document.location.href = items.url ? defaultURL
url = items.url ? defaultURL
if url
documentReady ->
chrome.tabs.getSelected null, (tab) ->
chrome.tabs.update tab.id, { url }

This comment has been minimized.

Copy link
@weakish

weakish May 14, 2015

chrome.tabs.update { url: url }

Without specifying tab.id, chrome.tabs.update will update the selected tab of current window.

Thus we do not need chrome.tabs.getSelected.
Thus tabs is not needed in permissions.


2 comments on commit b2d9204

@smblott-github
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know more about this than me... Submit a PR?

@weakish
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submit a PR?

What's the license of chrome-new-tab-url?

Please sign in to comment.