File tree 5 files changed +19
-20
lines changed
5 files changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var selectedItem = null;
4
4
var selectedId = null ;
5
5
6
6
function updateItem ( tabId ) {
7
- chrome . tabs . sendRequest ( tabId , { } , function ( item ) {
7
+ chrome . tabs . sendMessage ( tabId , { } , function ( item ) {
8
8
items [ tabId ] = item ;
9
9
if ( ! item ) {
10
10
chrome . pageAction . hide ( tabId ) ;
Original file line number Diff line number Diff line change 1
1
if ( window == top ) {
2
- chrome . extension . onRequest . addListener ( function ( req , sender , senderResponse ) {
2
+ chrome . extension . onMessage . addListener ( function ( req , sender , senderResponse ) {
3
3
senderResponse ( findItemID ( ) ) ;
4
4
} ) ;
5
5
}
Original file line number Diff line number Diff line change 5
5
"description" : " Generate an Amazon affiliate link with one click" ,
6
6
"background" : {
7
7
"scripts" : [" jq.min.js" ," bg.js" ],
8
- "persistent" : false
8
+ "persistent" : true
9
9
},
10
10
"icons" : {
11
11
"16" : " images/icon_16.png" ,
Original file line number Diff line number Diff line change 3
3
< title > Popup</ title >
4
4
< style >
5
5
body {
6
- width : 300 px ;
6
+ width : 400 px ;
7
7
}
8
8
9
9
label {
14
14
15
15
input [type = 'text' ] {
16
16
display : inline-block;
17
- width : 200 px ;
17
+ width : 300 px ;
18
18
}
19
19
</ style >
20
20
</ head >
24
24
</ body >
25
25
< script src ="jq.min.js "> </ script >
26
26
< script src ="jquery.url.js "> </ script >
27
- < script >
28
- window . onload = function ( ) {
29
- var item = chrome . extension . getBackgroundPage ( ) . selectedItem ;
30
- if ( item ) {
31
- chrome . tabs . getSelected ( null , function ( tab ) {
32
- var tablink = tab . url ,
33
- host = $ . url ( tablink ) . attr ( 'host' ) ,
34
- link = 'http://' + host + '/dp/' + item + '/?tag='
35
- + localStorage [ 'trackId' ] ;
36
- console . log ( link ) ;
37
- $ ( '#txt' ) . val ( link ) ;
38
- } ) ;
39
- }
40
- }
41
- </ script >
27
+ < script src ="popup.js "> </ script >
42
28
</ html >
Original file line number Diff line number Diff line change
1
+ window . onload = function ( ) {
2
+ var item = chrome . extension . getBackgroundPage ( ) . selectedItem ;
3
+ if ( item ) {
4
+ chrome . tabs . getSelected ( null , function ( tab ) {
5
+ var tablink = tab . url ,
6
+ host = $ . url ( tablink ) . attr ( 'host' ) ,
7
+ link = 'http://' + host + '/dp/' + item + '/?tag='
8
+ + localStorage [ 'trackId' ] ;
9
+ console . log ( link ) ;
10
+ $ ( '#txt' ) . val ( link ) ;
11
+ } ) ;
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments