Last active
October 4, 2015 00:58
-
-
Save xl1/2550213 to your computer and use it in GitHub Desktop.
open phone2chrome last synced page (Chrome extention)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PAGES_URL = "http://dl.dropboxusercontent.com/s/***/pages" # Dropbox/phone2chrome/pages | |
openedURLs = [] | |
getPages = (callback) -> | |
xhr = new XMLHttpRequest() | |
xhr.open 'GET', PAGES_URL, true | |
xhr.onload = -> | |
text = xhr.responseText | |
start = text.indexOf '{' | |
last = text.lastIndexOf '}' | |
callback text[start..last] | |
xhr.send() | |
openPage = -> | |
getPages (json) -> | |
pages = (JSON.parse json).pages | |
while pages.length > 0 | |
lastPage = pages.pop() | |
if lastPage.url not in openedURLs | |
openedURLs.push lastPage.url | |
chrome.tabs.create { url: lastPage.url } | |
return | |
chrome.browserAction.onClicked.addListener openPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "phone2chrome last synced page", | |
"version": "1.0", | |
"manifest_version": 2, | |
"browser_action": { | |
"default_icon": "icon.png" | |
}, | |
"background": { | |
"scripts": [ | |
"background.js" | |
] | |
}, | |
"permissions": [ | |
"tabs", | |
"http://dl.dropboxusercontent.com/" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment