diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 2547a88..d3ffd27 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -This is Forked from a great, simple extension from **[@ryanmcgrath](http://twitter.com/ryanmcgrath)** from **[here](https://github.com/ryanmcgrath/takeoff)**. - Takeoff --------------------------------------------------------------------------- I was up late one night, and my brain was in one of those modes where I needed @@ -15,8 +13,8 @@ run with it as you see fit. MIT licensed. To Install ---------------------------------------------------------------------------- -Download it, unzip it somewhere, load it up in your **[extensions tab](chrome://extensions/)** by loading -an "unpacked" extension. Or, just drag and drop...easy. NOTE: You must enable developer tools to get this to work. +Download it, unzip it somewhere, load it up in your extensions tab by loading +an "unpacked" extension. Publicity --------------------------------------------------------------------------- diff --git a/manifest.json b/manifest.json old mode 100644 new mode 100755 index c21ecfa..2239c4a --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "name": "Takeoff", - "version": "1.0", + "version": "2.0", "description": "Takeoff grabs a random entry from your Bookmarks collection and loads it when you start the browser or open a new tab.", "chrome_url_overrides": { "newtab": "takeoff.html" }, - "manifest-version": 2, + "manifest_version": 2, "permissions": ["tabs", "bookmarks"] } diff --git a/takeoff.html b/takeoff.html old mode 100644 new mode 100755 index d5d35eb..cac1a54 --- a/takeoff.html +++ b/takeoff.html @@ -3,40 +3,7 @@ - + diff --git a/takeoff.js b/takeoff.js new file mode 100644 index 0000000..35db08c --- /dev/null +++ b/takeoff.js @@ -0,0 +1,34 @@ +var marks = []; + +chrome.bookmarks.getTree(function(itemTree){ + itemTree.forEach(function(item){ + processNode(item); + }); +}); + +function processNode(node) { + + // recursively process child nodes + if(node.children) { + node.children.forEach(function(child) { + processNode(child); + }); + } + + // print leaf nodes URLs to console + if(node.url) { + console.log(node.url); + var book = marks.push(node.url); + } +} + + + +function setPage(windowObj) { + bookmark = marks[Math.floor(Math.random() * marks.length)]; + chrome.tabs.getSelected(windowObj.windowId, function(tab) { + chrome.tabs.update(tab.id, {url: bookmark}); + }); +} + +chrome.windows.getLastFocused(setPage); \ No newline at end of file