Skip to content
Browse files

Fixed Chrome JavaScript.

  • Loading branch information...
1 parent 9bf8ec8 commit f40822fb8287bb08cad79a4e05c5a4c133d2c7fa @nathan-osman committed Jan 18, 2012
Showing with 24 additions and 32 deletions.
  1. +3 −0 chrome/auth.js
  2. +0 −27 chrome/auth_complete.html
  3. +9 −2 chrome/background.html
  4. +11 −2 chrome/manifest.json
  5. +1 −1 common/stackalert.js
View
3 chrome/auth.js
@@ -0,0 +1,3 @@
+// Send the hash to complete the authorization
+chrome.extension.sendRequest({ command: 'authorize',
+ hash: window.location.hash });
View
27 chrome/auth_complete.html
@@ -1,27 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <!-- Include our stylesheet and JavaScript utility library -->
- <link href="style.css" rel="stylesheet" />
- <script src="stackalert.js"></script>
- <script src="chrome.js"></script>
-</head>
-<body>
- <script>
-
- var message = StackAlert.CompleteAuthorization(location);
-
- if(message == '') {
-
- // Send a message to the background page to refresh
- chrome.extension.sendRequest({});
-
- window.close();
-
- }
- else
- document.write('<h3>Error:</h3><p>An error has occurred:</p><pre>' + message + '</pre><button onclick="window.close();">Close</button>');
-
- </script>
-</body>
-</html>
View
11 chrome/background.html
@@ -11,9 +11,16 @@
StackAlert.PerformUpdate();
// Listen for requests to update the data
-chrome.extension.onRequest.addListener(function() {
+chrome.extension.onRequest.addListener(function(request, sender) {
- StackAlert.PerformUpdate();
+ // The command to perform is listed in request
+ if(request.command == 'update')
+ StackAlert.PerformUpdate();
+ else if(request.command == 'authorize') {
+ StackAlert.CompleteAuthorization(request.hash);
+ chrome.tabs.remove(sender.tab.id);
+ StackAlert.PerformUpdate();
+ }
});
View
13 chrome/manifest.json
@@ -1,6 +1,6 @@
{
"name": "Stack Alert",
- "version": "0.18",
+ "version": "0.21",
"description": "Monitors the inbox of a Stack Exchange account for new items.",
"icons": { "16": "icon16.png",
"48": "icon48.png",
@@ -13,7 +13,16 @@
"default_icon": "badge.png",
"popup": "popup.html"
},
+ "content_scripts": [
+ {
+ "matches": ["https://stackexchange.com/oauth/login_success*"],
+ "js": ["auth.js"]
+ }
+ ],
+
"permissions": [
- "https://api.stackexchange.com/"
+ "https://api.stackexchange.com/",
+ "notifications",
+ "tabs"
]
}
View
2 common/stackalert.js
@@ -432,7 +432,7 @@ var StackAlert = {
button.addEventListener('click', function() {
StackAlert.ResetError();
- window.reload();
+ location.href = location.href;
}, true);

0 comments on commit f40822f

Please sign in to comment.
Something went wrong with that request. Please try again.