Commits

Alexey Kozlov committed cb500a8

version 1.2

Comments (0)

Files changed (2)

 {
    "name": "L-Cube",
    "description": "Making breadcrumbs from URL",
-   "version": "1.1",
+   "version": "1.2",
    "background_page": "background.html",
    "options_page": "options.html",
    "page_action": {
  <style>
   body {
     min-width:500px;
-    /*overflow-x:hidden;*/
   }
   div {
     padding:0 10px 10px 10px;
  </style>
  <script type="text/javascript">
 
-  chrome.tabs.executeScript(null, {code: "chrome.extension.sendRequest(document.URL);"});
-  chrome.extension.onRequest.addListener(function(request) { parse_url(request) });
+  chrome.tabs.executeScript(null, {code: "l=document.getElementsByTagName('link');s={};for(i in l){if(l[i].rel=='prev'||l[i].rel=='next'){s[l[i].rel] = l[i].href;}}chrome.extension.sendRequest([document.URL,s]);"});
+
+  chrome.extension.onRequest.addListener(function(request) {
+    parse_url(request[0]);
+    if (request[1]['prev'] || request[1]['next']) {
+
+      parse_links(request[1]);
+
+    }
+  });
+
+  function parse_links(request) {
+
+    output_div = document.getElementById("output");
+    tmp_hr = document.createElement("hr");
+    output_div.appendChild(tmp_hr);
+    tmp_para = document.createElement("p");
+
+    if (request['prev']) {
+
+      tmp_a = document.createElement("a");
+      tmptext = document.createTextNode('prev');
+      tmp_a.appendChild(tmptext);
+      tmp_para.appendChild(tmp_a);
+      tmp_a.setAttribute("href", request['prev']);
+      tmp_a.setAttribute("onClick", "javascript:run_link('" + request['prev'] + "');return false");
+
+    }
+    if (request['prev'] && request['next']) {
+
+      tmptext = document.createTextNode(' || ');
+      tmp_para.appendChild(tmptext);
+
+    }
+    if (request['next']) {
+
+      tmp_a = document.createElement("a");
+      tmptext = document.createTextNode('next');
+      tmp_a.appendChild(tmptext);
+      tmp_para.appendChild(tmp_a);
+      tmp_a.setAttribute("href", request['next']);
+      tmp_a.setAttribute("onClick", "javascript:run_link('" + request['next'] + "');return false");
+
+    }
+    output_div.appendChild(tmp_para);
+
+  }
 
   function parse_url(request) {