OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
1 // The background page is asking us to find an address on the page. | 5 // The background page is asking us to find an address on the page. |
2 if (window == top) { | 6 if (window == top) { |
3 chrome.extension.onRequest.addListener(function(req, sender, sendResponse) { | 7 chrome.extension.onRequest.addListener(function(req, sender, sendResponse) { |
4 sendResponse(findAddress()); | 8 sendResponse(findAddress()); |
5 }); | 9 }); |
6 } | 10 } |
7 | 11 |
8 // Search the text nodes for a US-style mailing address. | 12 // Search the text nodes for a US-style mailing address. |
9 // Return null if none is found. | 13 // Return null if none is found. |
10 var findAddress = function() { | 14 var findAddress = function() { |
(...skipping 28 matching lines...) Expand all Loading... |
39 var trim = /\s{2,}/g; | 43 var trim = /\s{2,}/g; |
40 return match[0].replace(trim, " "); | 44 return match[0].replace(trim, " "); |
41 } else { | 45 } else { |
42 console.log("bad initial match: " + found.textContent); | 46 console.log("bad initial match: " + found.textContent); |
43 console.log("no match in: " + text); | 47 console.log("no match in: " + text); |
44 } | 48 } |
45 } | 49 } |
46 return null; | 50 return null; |
47 } | 51 } |
48 | 52 |
OLD | NEW |