Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit 952898ea00105899a3f1920dceae5621f5d5b2a9 unknown committed Mar 18, 2012
Showing with 138 additions and 0 deletions.
  1. +25 −0 background.html
  2. +26 −0 contentscript.js
  3. BIN logo-128.png
  4. BIN logo-19.png
  5. BIN logo-48.png
  6. +31 −0 manifest.json
  7. +56 −0 popup.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<!--
+ * Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
+ * source code is governed by a BSD-style license that can be found in the
+ * LICENSE file.
+-->
+<html>
+ <head>
+ <script>
+ // Called when a message is passed. We assume that the content script
+ // wants to show the page action.
+ function onRequest(request, sender, sendResponse) {
+ // Show the page action for the tab that the sender (content script)
+ // was on.
+ chrome.pageAction.show(sender.tab.id);
+
+ // Return nothing to let the connection be cleaned up.
+ sendResponse({});
+ };
+
+ // Listen for the content script to send a message to the background page.
+ chrome.extension.onRequest.addListener(onRequest);
+ </script>
+ </head>
+</html>
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
+ * source code is governed by a BSD-style license that can be found in the
+ * LICENSE file.
+ */
+var regex = /reportpartnumber/;
+
+// Test the text of the body element against our regular expression.
+
+if (regex.test(document.body.innerHTML)) {
+ // The regular expression produced a match, so notify the background page.
+ chrome.extension.sendRequest({}, function(response) {});
+ var partCell = document.getElementById('reportpartnumber');
+ var partInfos = partCell.parentElement.parentElement.getElementsByTagName('th');
+ for(var i=0; i<partInfos.length;i++){
+ if (partInfos[i].innerText == 'Manufacturer Part Number') {
+ cell = partInfos[i].parentElement.getElementsByTagName('td')[0];
+ partid = cell.innerText
+ newcell = '<a href="https://circuithub.com/parts/search?q='+partid+'">'+partid+'</a>';
+ cell.innerHTML = newcell;
+ }
+ }
+
+} else {
+ // No match was found.
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,31 @@
+{
+ "name" : "CircuitHub",
+ "version" : "1.0",
+ "description" : "Link To Parts in CircuitHub",
+ "background_page" : "background.html",
+ "page_action" :
+ {
+ "default_icon" : "logo-19.png",
+ "default_title" : "Locate Parts in Page",
+ "popup": "popup.html"
+ },
+ "content_scripts" : [
+ {
+ "matches" : [
+ "http://search.digikey.com/us/en/*",
+ "https://search.digikey.com/us/en/*"
+ ],
+ "js" : ["contentscript.js"],
+ "run_at" : "document_end",
+ "all_frames" : false
+ }
+ ],
+ "icons" : {
+ "48" : "logo-48.png",
+ "128" : "logo-128.png"
+ },
+ "permissions": [
+ "http://api.flickr.com/",
+ "http://circuithub.com/"
+ ]
+}
@@ -0,0 +1,56 @@
+<div>This should search the DB
+And provide a link to the part on circuit hub!</div>
+<a href='https://circuithub.com/'>CircuitHub</a>
+<p>
+
+<style>
+body {
+ min-width:357px;
+ overflow-x:hidden;
+}
+
+img {
+ margin:5px;
+ border:2px solid black;
+ vertical-align:middle;
+ width:75px;
+ height:75px;
+}
+</style>
+
+<script>
+var req = new XMLHttpRequest();
+req.open(
+ "GET",
+ "http://api.flickr.com/services/rest/?" +
+ "method=flickr.photos.search&" +
+ "api_key=90485e931f687a9b9c2a66bf58a3861a&" +
+ "text=hello%20world&" +
+ "safe_search=1&" + // 1 is "safe"
+ "content_type=1&" + // 1 is "photos only"
+ "sort=relevance&" + // another good one is "interestingness-desc"
+ "per_page=20",
+ true);
+req.onload = showPhotos;
+req.send(null);
+
+function showPhotos() {
+ var photos = req.responseXML.getElementsByTagName("photo");
+
+ for (var i = 0, photo; photo = photos[i]; i++) {
+ var img = document.createElement("image");
+ img.src = constructImageURL(photo);
+ document.body.appendChild(img);
+ }
+}
+
+// See: http://www.flickr.com/services/api/misc.urls.html
+function constructImageURL(photo) {
+ return "http://farm" + photo.getAttribute("farm") +
+ ".static.flickr.com/" + photo.getAttribute("server") +
+ "/" + photo.getAttribute("id") +
+ "_" + photo.getAttribute("secret") +
+ "_s.jpg";
+}
+</script>
+</p>

0 comments on commit 952898e

Please sign in to comment.