40
loading...
This website collects cookies to deliver better user experience
manifest.json
content.js
{
"manifest_version": 2,
"name": "FriendsFX",
"version": "1.0.1",
"description": "Converts every image on a webpage to random pictures of some of my friends",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}
"content_scripts"
key. "matches"
and "js"
, with values of ["<all_urls>"]
and ["content.js"]
respectively.["<all_urls>"]
basically matches any URL that starts with a permitted scheme; http:, https:, file:, ftp:, or chrome-extension:. imagesLinks
, containing links to those pictures.// An array of pictures to randomly select from
// You can have as many links/pictures as you want
const imagesLinks = [
"https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511199/friendsFX/IMG20201223190841_1_gsz2dc.jpg",
"https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511198/friendsFX/IMG20201223184904_tj8u3d.jpg",
"https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511192/friendsFX/IMG20201223182200_xglqvv.jpg",
"https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511189/friendsFX/IMG20201223191703_wnindo.jpg",
"https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511184/friendsFX/IMG20201223182912_er8kil.jpg"
]
// fetches all <img> tags on the webpage
const imageTags = document.getElementsByTagName("img")
// Loops through each of the <img> tags on the webpage
// Replaces the 'src' attribute with a random link from the imageLinks array
// Do this every 4 seconds
setInterval(() => {
for (let i = 0; i < imageTags.length; i++) {
let randomArrayIndex = Math.floor(Math.random() * imagesLinks.length)
imageTags[i].src = imagesLinks[randomArrayIndex]
}
}, 4000);