Commits

Adrian Sampson  committed 7c80d76

actually show a popup with the short link

  • Participants
  • Parent commits c589f22

Comments (0)

Files changed (3)

File background.html

-<html>
-<head>
-<script>
-chrome.browserAction.onClicked.addListener(function(tab) {
-    chrome.tabs.sendRequest(tab.id, {}, function(url) {
-        if (url == null) {
-            // Fall back to current URL if no short one found.
-            url = tab.url;
-        }
-        console.log(url);
-    });
-});
-</script>
-</head>
-</html>
-

File manifest.json

     "description": "Finds canonical short URLs.",
     "browser_action": {
         "default_title": "Get short URL",
-        "default_icon": "icon.png"
+        "default_icon": "icon.png",
+	"default_popup": "popup.html"
     },
     "permissions": [
         "tabs"
             "matches": ["http://*/*"],
             "js": ["content_script.js"]
         }
-    ],
-    "background_page": "background.html"
+    ]
 }
 
+<html>
+<head>
+<style>
+#shortlink {
+	display: block;
+	white-space: nowrap;
+}
+</style>
+<script>
+function findLink(tab) {
+    chrome.tabs.sendRequest(tab.id, {}, function(url) {
+        if (url == null) {
+            // Fall back to current URL if no short one found.
+            url = tab.url;
+        }
+        console.log(url);
+
+	var linkel = document.getElementById("shortlink");
+	linkel.textContent = url;
+	a.href = url;
+    });
+}
+
+var tab = chrome.tabs.getSelected(null, function(tab) {
+    findLink(tab);
+});
+</script>
+</head>
+<body>
+Short link:
+<a href="#" id="shortlink">???</span>
+</body>
+</html>
+