Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

restructure

  • Loading branch information...
commit eba402f5d8b62819f4603ad2dfc8dc4bb7438f72 1 parent d4bfa42
Dennis Hall authored
120 contentscript.js → src/contentscript.js
... ... @@ -1,60 +1,60 @@
1   -/**
2   - * Copyright (c) 2011 Dennis Hall <https://github.com/dennishall>.
3   - * All rights reserved. Use of this source code is governed by the MIT license.
4   -**/
5   -
6   -
7   -function $(s){
8   - return document.querySelectorAll(s);
9   -}
10   -
11   -function prepend(child){
12   - this.insertBefore(child, this.firstChild);
13   -}
14   -
15   -function copyToClipboard( text ){
16   -
17   - // chrome.extension.getBackgroundPage().copy(text);
18   - // var te = document.createElement('textarea');
19   - // prepend.call(listing_details, te);
20   - listing_details.innerHTML = '<textarea id="te"></textarea>';
21   - var te = $('#te')[0]
22   - te.value = text;
23   - te.rows = 4;
24   - te.style.fontStyle = "normal";
25   - te.columns = 30;
26   - te.select();
27   -
28   - // doesn't work!!!
29   - // document.body.contentEditable = true;
30   - // doesn't work!!!
31   - document.execCommand('copy');
32   -
33   - // copyDiv.unselectable = "off";
34   - // copyDiv.focus();
35   - // document.execCommand('SelectAll');
36   - // document.execCommand("Copy", false, null);
37   - // document.body.removeChild(copyDiv);
38   -}
39   -
40   -var listing_details = $('.listing_detail_details')[0];
41   -
42   -if(listing_details){
43   - //remove unwanted elements
44   - var tbl = $('table')[0].cloneNode(true);
45   - [].forEach.call($('.secondary-button, table'), function(el){
46   - el.parentNode.removeChild(el);
47   - });
48   - //massage the text
49   - prepend.call(listing_details, $('h1')[0]);
50   - var zip = $('.postal-code')[0];
51   - zip.innerText = zip.innerText.replace(/(\d{5})-?.*/, "$1");
52   - var text = listing_details.innerText;
53   - copyToClipboard( text );
54   - listing_details.appendChild(tbl);
55   - // alert('copied to clipboard');
56   -
57   - // console.log("copying .. ", text);
58   - // chrome.extension.sendMessage(text);
59   -
60   -}
  1 +/**
  2 + * Copyright (c) 2011 Dennis Hall <https://github.com/dennishall>.
  3 + * All rights reserved. Use of this source code is governed by the MIT license.
  4 +**/
  5 +
  6 +
  7 +function $(s){
  8 + return document.querySelectorAll(s);
  9 +}
  10 +
  11 +function prepend(child){
  12 + this.insertBefore(child, this.firstChild);
  13 +}
  14 +
  15 +function copyToClipboard( text ){
  16 +
  17 + // chrome.extension.getBackgroundPage().copy(text);
  18 + // var te = document.createElement('textarea');
  19 + // prepend.call(listing_details, te);
  20 + listing_details.innerHTML = '<textarea id="te"></textarea>';
  21 + var te = $('#te')[0]
  22 + te.value = text;
  23 + te.rows = 4;
  24 + te.style.fontStyle = "normal";
  25 + te.columns = 30;
  26 + te.select();
  27 +
  28 + // doesn't work!!!
  29 + // document.body.contentEditable = true;
  30 + // doesn't work!!!
  31 + document.execCommand('copy');
  32 +
  33 + // copyDiv.unselectable = "off";
  34 + // copyDiv.focus();
  35 + // document.execCommand('SelectAll');
  36 + // document.execCommand("Copy", false, null);
  37 + // document.body.removeChild(copyDiv);
  38 +}
  39 +
  40 +var listing_details = $('.listing_detail_details')[0];
  41 +
  42 +if(listing_details){
  43 + //remove unwanted elements
  44 + var tbl = $('table')[0].cloneNode(true);
  45 + [].forEach.call($('.secondary-button, table'), function(el){
  46 + el.parentNode.removeChild(el);
  47 + });
  48 + //massage the text
  49 + prepend.call(listing_details, $('h1')[0]);
  50 + var zip = $('.postal-code')[0];
  51 + zip.innerText = zip.innerText.replace(/(\d{5})-?.*/, "$1");
  52 + var text = listing_details.innerText;
  53 + copyToClipboard( text );
  54 + listing_details.appendChild(tbl);
  55 + // alert('copied to clipboard');
  56 +
  57 + // console.log("copying .. ", text);
  58 + // chrome.extension.sendMessage(text);
  59 +
  60 +}
2  contentstyle.css → src/contentstyle.css
... ... @@ -1 +1 @@
1   -.secondary-button { display: none; }
  1 +.secondary-button { display: none; }
40 manifest.json → src/manifest.json
... ... @@ -1,20 +1,20 @@
1   -{
2   - "name" : "Whitepages Helper",
3   - "version" : "1.0",
4   - "manifest_version": 2,
5   - "description" : "Hides a couple buttons, makes it easier to copy and paste addresses.",
6   - "permissions" : [
7   - "clipboardRead",
8   - "clipboardWrite"
9   - ],
10   - "content_scripts" : [
11   - {
12   - "matches" : [
13   - "http://www.whitepages.com/*"
14   - ],
15   - "js" : ["contentscript.js"],
16   - "css" : ["contentstyle.css"],
17   - "all_frames" : false
18   - }
19   - ]
20   -}
  1 +{
  2 + "name" : "Whitepages Helper",
  3 + "version" : "1.0",
  4 + "manifest_version": 2,
  5 + "description" : "Hides a couple buttons, makes it easier to copy and paste addresses.",
  6 + "permissions" : [
  7 + "clipboardRead",
  8 + "clipboardWrite"
  9 + ],
  10 + "content_scripts" : [
  11 + {
  12 + "matches" : [
  13 + "http://www.whitepages.com/*"
  14 + ],
  15 + "js" : ["contentscript.js"],
  16 + "css" : ["contentstyle.css"],
  17 + "all_frames" : false
  18 + }
  19 + ]
  20 +}
BIN  whitepages-chrome-extension.crx
Binary file not shown

0 comments on commit eba402f

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