mirror of
https://github.com/fergalmoran/Chrome2Kindle.git
synced 2025-12-22 09:38:38 +00:00
More oauth stuff
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="chrome_ex_oauthsimple.js"></script>
|
||||
<script type="text/javascript" src="chrome_ex_oauth.js"></script>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="background.js" type="text/javascript"></script>
|
||||
<script>
|
||||
|
||||
var oauth = ChromeExOAuth.initBackgroundPage({
|
||||
'request_url' : 'https://www.google.com/accounts/OAuthGetRequestToken',
|
||||
'authorize_url' : 'https://www.google.com/accounts/OAuthAuthorizeToken',
|
||||
'access_url' : 'https://www.google.com/accounts/OAuthGetAccessToken',
|
||||
'consumer_key' : 'anonymous',
|
||||
'consumer_secret' : 'anonymous',
|
||||
'scope' : 'https://docs.google.com/feeds/',
|
||||
'app_name' : 'Chrome 2 Kindle'
|
||||
});
|
||||
|
||||
function addBookmark(title, url, parentId){
|
||||
chrome.bookmarks.create({
|
||||
'parentId' : parentId,
|
||||
@@ -11,11 +23,18 @@
|
||||
'url' : url
|
||||
});
|
||||
}
|
||||
function authorise(){
|
||||
oauth.authorize(function(){
|
||||
alert('You is authorized lol 1');
|
||||
});
|
||||
}
|
||||
chrome.extension.onRequest.addListener(
|
||||
function(request, sender, sendResponse){
|
||||
if (request.message = 'create_bookmark'){
|
||||
if (request.message == 'create_bookmark'){
|
||||
addBookmark(request.title, request.url, request.parentId);
|
||||
sendResponse('Bookmark created');
|
||||
}else if(request.message == 'authorise'){
|
||||
authorise();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
},
|
||||
"permissions" : [
|
||||
"http://chrome2kindle.appspot.com/",
|
||||
"https://www.google.com/accounts/OAuthGetRequestToken",
|
||||
"https://www.google.com/accounts/OAuthAuthorizeToken",
|
||||
"https://www.google.com/accounts/OAuthGetAccessToken",
|
||||
"http://fermi.wasptech.com/",
|
||||
"bookmarks",
|
||||
"tabs"
|
||||
|
||||
@@ -98,6 +98,14 @@
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" id="use_oauth">Store preferences?</td>
|
||||
<td><button onclick="authorise()">Authorise</button></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">No reason for this at the moment, but will be adding features which will need this.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
|
||||
@@ -22,6 +22,13 @@ $(document).ready(function () {
|
||||
//chrome.bookmarks.get(id,
|
||||
});
|
||||
|
||||
function authorise(){
|
||||
chrome.extension.sendRequest({
|
||||
message : 'authorise'
|
||||
}, function (result){
|
||||
alert('You is authorised lol.');
|
||||
});
|
||||
}
|
||||
function isValidEmailAddress(emailAddress) {
|
||||
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
|
||||
return pattern.test(emailAddress);
|
||||
|
||||
Reference in New Issue
Block a user