File tree 5 files changed +130
-0
lines changed
5 files changed +130
-0
lines changed Original file line number Diff line number Diff line change
1
+ body {
2
+ margin : 0 ;
3
+ padding : 10px ;
4
+ font-family : Arial, Helvetica, sans-serif;
5
+ font-size : 16px ;
6
+ background-color : # f2f2f2 ;
7
+ }
8
+
9
+ input {
10
+ width : 100% ;
11
+ padding : 10px ;
12
+ box-sizing : border-box;
13
+ border : 1px solid # 5f9341 ;
14
+ margin-bottom : 4px ;
15
+ }
16
+
17
+ button {
18
+ background : # 5f9341 ;
19
+ color : white;
20
+ padding : 10px 20px ;
21
+ border : 1px solid # 5f9341 ;
22
+ font-weight : bold;
23
+ cursor : pointer;
24
+ }
25
+
26
+ # delete-btn {
27
+ background : white;
28
+ color : # 5f9341 ;
29
+ }
30
+
31
+ ul {
32
+ margin-top : 20px ;
33
+ list-style : none;
34
+ padding-left : 0 ;
35
+ }
36
+
37
+ li {
38
+ margin-top : 5px ;
39
+ padding : 10px ;
40
+ background-color : white;
41
+ border : 1px solid # 5f9341 ;
42
+ display : flex;
43
+ justify-content : space-between;
44
+ align-items : center;
45
+ }
46
+
47
+ a {
48
+ color : # 5f9341 ;
49
+ }
50
+
51
+
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 " />
5
+ < title > Chrome Extension</ title >
6
+ < link
7
+ rel ="stylesheet "
8
+ href ="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css "
9
+ />
10
+ < link rel ="stylesheet " href ="index.css " />
11
+ </ head >
12
+ < body >
13
+ < input type ="text " id ="input-el " />
14
+ < button id ="input-btn "> SAVE INPUT</ button >
15
+ < button id ="tab-btn "> SAVE TAB</ button >
16
+ < button id ="delete-btn "> DELETE ALL</ button >
17
+ < ul id ="ul-el "> </ ul >
18
+ < script src ="index.js "> </ script >
19
+ </ body >
20
+ </ html >
Original file line number Diff line number Diff line change
1
+ let myLeads = [ ]
2
+ const inputEl = document . getElementById ( "input-el" )
3
+ const inputBtn = document . getElementById ( "input-btn" )
4
+ const ulEl = document . getElementById ( "ul-el" )
5
+ const deleteBtn = document . getElementById ( "delete-btn" )
6
+ const leadsFromLocalStorage = JSON . parse ( localStorage . getItem ( "myLeads" ) )
7
+ const tabBtn = document . getElementById ( "tab-btn" )
8
+
9
+ if ( leadsFromLocalStorage ) {
10
+ myLeads = leadsFromLocalStorage
11
+ render ( myLeads )
12
+ }
13
+
14
+ tabBtn . addEventListener ( "click" , function ( ) {
15
+ chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) {
16
+ myLeads . push ( tabs [ 0 ] . url )
17
+ localStorage . setItem ( "myLeads" , JSON . stringify ( myLeads ) )
18
+ render ( myLeads )
19
+ } )
20
+ } )
21
+
22
+ function render ( leads ) {
23
+ let listItems = ""
24
+ for ( let i = 0 ; i < leads . length ; i ++ ) {
25
+ listItems += `
26
+ <li>
27
+ <a target='_blank' href='${ leads [ i ] } '>
28
+ ${ leads [ i ] }
29
+ </a>
30
+ </li>
31
+ `
32
+ }
33
+ ulEl . innerHTML = listItems
34
+ }
35
+
36
+ deleteBtn . addEventListener ( "dblclick" , function ( ) {
37
+ localStorage . clear ( )
38
+ myLeads = [ ]
39
+ render ( myLeads )
40
+ } )
41
+
42
+ inputBtn . addEventListener ( "click" , function ( ) {
43
+ myLeads . push ( inputEl . value )
44
+ inputEl . value = ""
45
+ localStorage . setItem ( "myLeads" , JSON . stringify ( myLeads ) )
46
+ render ( myLeads )
47
+ } )
Original file line number Diff line number Diff line change
1
+ {
2
+ "manifest_version" : 3 ,
3
+ "version" : " 1.0" ,
4
+ "name" : " Ajay Dhangar" ,
5
+ "action" : {
6
+ "default_popup" : " index.html" ,
7
+ "default_icon" : " icon.png"
8
+ },
9
+ "permissions" : [
10
+ " tabs"
11
+ ]
12
+ }
You can’t perform that action at this time.
0 commit comments