-
Notifications
You must be signed in to change notification settings - Fork 0
/
change.js
21 lines (16 loc) · 827 Bytes
/
change.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
chrome.storage.sync.get(["searchWord"], function(data) { // Get value from Chrome Storage
if (typeof data.searchWord === 'undefined') {} // Check to see if values have been set
else {
let word = data.searchWord; // Assign value to data
if (document.documentElement.innerHTML.indexOf(word) > -1) { // Search page for a string
chrome.storage.sync.get(["usrImgs"], function(data) { // Get value from Chrome Storage
let replacements = data.usrImgs; // Assign value to data
let imgs = document.images; // Grab all images on page
for (let i in imgs) { // loop for each image
let rand = Math.floor(Math.random() * replacements.length); // Pick a random number
document.images[i].src = replacements[rand]; // Change the image's source
}
});
}
}
});