-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
45 lines (40 loc) · 1.15 KB
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Icon source: Marvin Robot by Creaticca Creative Agency from the Noun Project
let inputs = document.querySelectorAll('input')
let selects = document.querySelectorAll('select')
let textareas = document.querySelectorAll('textarea');
function fillTheThings(){
inputs.forEach(input => {
switch( input.type ) {
case 'text':
const items = [`sigh`, `why`, `what's the use`, `uughh`]
input.value = items[Math.floor(Math.random()*items.length)]
break
case 'checkbox':
input.checked = true
break
case 'email':
input.value = `marvin@magrathea.com`
break
case 'tel':
input.value = `647 424 2424`
break
case 'number':
input.value = `42`
break
}
})
selects.forEach(select => {
select.selectedIndex = 1
})
textareas.forEach(textarea => {
textarea.value = `“What’s up?” asked Ford.
“I don’t know,” said Marvin, “I’ve never been there.”`
})
}
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if( request.message === "clicked_browser_action" ) {
fillTheThings()
}
}
);