Skip to content

Commit d8b59fb

Browse files
committed
config popup
1 parent eec4189 commit d8b59fb

File tree

6 files changed

+83
-19
lines changed

6 files changed

+83
-19
lines changed

content.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

manifest.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
"name" : "UkePass",
44
"version": "0.1",
55
"description":"Salva suas senhas",
6-
"icons": {"128":"./src/icon.png"},
7-
"permissions" : ["activeTab"],
6+
"icons": {"128":"./src/assets/icon.png"},
7+
"permissions" : ["activeTab","tabs"],
8+
"browser_action":{
9+
"default_popup" : "./src/pages/popup.html"
10+
},
811
"content_scripts":[
912
{
1013
"matches" : [
11-
"http://localhost/aplicacoes/WebImage/"
14+
"<all_urls>"
1215
],
13-
"js" : ["content.js"]
16+
"js" : ["./src/content.js"]
1417
}
1518
]
1619
}
File renamed without changes.

src/content.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
3+
function getPassword(e) {
4+
console.log(e.target.value);
5+
6+
}
7+
8+
let password = document.getElementsByTagName("input");
9+
password = Object.values(password);
10+
11+
12+
password.map((e) => {
13+
e.addEventListener("keyup", getPassword);
14+
});
15+
16+
console.log('Ukepass --- origin: content')
17+
18+
/**
19+
* Receiving popup message
20+
*/
21+
22+
chrome.runtime.onMessage.addListener(receiver);
23+
24+
// A message is received
25+
26+
function receiver(request, sender, sendResponse) {
27+
console.log(request.message);
28+
}

src/pages/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
/**
3+
* communication between index.js and content
4+
*/
5+
6+
let message = 'hello im a popup'
7+
let msg = {
8+
from: 'popup',
9+
message
10+
}
11+
// A tab has be selected for the message to be sent
12+
let params = {
13+
active: true,
14+
currentWindow: true
15+
}
16+
17+
// Now we've got the tabs
18+
function gotTabs(tabs) {
19+
// The first tab is the one you are on
20+
chrome.tabs.sendMessage(tabs[0].id, msg);//, messageBack);
21+
}
22+
23+
let clickEvent = document.getElementById('hello')
24+
25+
clickEvent.addEventListener('click',()=>{
26+
27+
// This searches for the active tabs in the current window
28+
29+
chrome.tabs.query(params, gotTabs);
30+
31+
});

src/pages/popup.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<h1>
11+
Hello Ukepass
12+
</h1>
13+
<input type="submit" id="hello">
14+
15+
<script src="./index.js" ></script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)