Skip to content

Commit

Permalink
first commit for the extension
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvibes committed Feb 1, 2024
0 parents commit b465470
Show file tree
Hide file tree
Showing 6 changed files with 407 additions and 0 deletions.
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

body{
margin: 0;
padding: 10px;
font-family: Arial, Helvetica, sans-serif;
min-width: 400px;
text-align: center;
}

#input-el {
width: 100%;
box-sizing: border-box;
padding: 10px;
border: 1px solid #5f9341;
}

button {
margin-top: 5px;
color: white;
background-color: rgb(56, 139, 56);
padding: 12px 25px;
border: 1px solid #5f9341;
font-weight: bold;
font-size: 1.1rem;
border-radius: 3px;
}

#delete-btn {
margin-top: 5px;
color: #5f9341;
background-color: white;
border: 1px solid #5f9341;
padding: 12px 25px;
font-weight: bold;
font-size: 1.1rem;
border-radius: 3px;
}

#delete-btn:hover {
background-color: #5f9341;
font-weight: bold;
font-size: 1.1rem;
color: white;
}

ul{
margin-top: 20px;
list-style: none;
padding-left: 0;
}

li{
margin-top: 5px;
}

li a {
color: #5f9341;
}


/* BOX EXAMPLE */

/* html, body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
#box {
cursor: pointer;
background-color: lightseagreen;
padding: 40px;
width: 200px;
text-align: center;
margin: 20px auto;
color: white;
font-weight: bold;
} */
27 changes: 27 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="index.css">
<title>Chrome extension</title>
</head>
<body>
<input type="text" id="input-el">
<button id="input-btn">SAVE INPUT</button>
<button id="tab-btn">SAVE TAB</button>
<button id="delete-btn">DELETE ALL</button>
<ul id="ul-el"></ul>

<!-- <button id="button-el">LOG JAMES SCORE</button> -->

<!-- <div id="box">Open the box</div> -->

<!-- <div id="buys"></div> -->

<!-- <p id="welcome-el"></p> -->

<script src="index.js"></script>
</body>
</html>
54 changes: 54 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// chrome://Extensions

let myLeads = []
let oldLeads = []
const inputEl = document.getElementById("input-el")
const inputBtn = document.getElementById("input-btn")
const ulEL = document.getElementById("ul-el")
const deleteBtn = document.getElementById("delete-btn")
const fromLocalStorage = JSON.parse( localStorage.getItem("myLeads") )
let tabBtn = document.getElementById("tab-btn")

if (fromLocalStorage) {
myLeads = fromLocalStorage
render(myLeads)
}

tabBtn.addEventListener("click", function(){
// console.log(tabs[0].url)
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
myLeads.push(tabs[0].url)
localStorage.setItem("myLeads", JSON.stringify(myLeads))
render(myLeads)
})

})

function render(Leads) {
let listItems = ""
for (i = 0; i < Leads.length; i++) {
// listItems += "<li><a target='_blank' href='" + myLeads[i] + "'>" + myLeads[i] + "</a></li>"
listItems += `
<li>
<a target='_blank' href='${Leads[i]}'>
${Leads[i]}
</a>
</li>`
}
ulEL.innerHTML = listItems
}

deleteBtn.addEventListener("dblclick", function() {
localStorage.clear()
myLeads = []
render(myLeads)
})

inputBtn.addEventListener("click", function() {
myLeads.push(inputEl.value)
inputEl.value = ""
localStorage.setItem("myLeads", JSON.stringify(myLeads))
render(myLeads)
console.log(localStorage.getItem("myLeads"))
})

13 changes: 13 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"manifest_version": 3,
"version": "1.0",
"name": "Leads Tracker",
"action": {
"default_popup": "index.html",
"default_icon": "icon.png"
},
"permissions": [
"tabs"
]

}
Loading

0 comments on commit b465470

Please sign in to comment.