-
Notifications
You must be signed in to change notification settings - Fork 7
/
favicon-replacer.js
31 lines (29 loc) · 1.35 KB
/
favicon-replacer.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
// ==UserScript==
// @name Dark Facebook Messenger Theme
// @description 🕶️ Cool dark red Facebook Messenger theme
// @namespace https://github.com/knutkirkhorn
// @version 2.0.2
// @license MIT
// @author Knut Kirkhorn
// @grant none
// @homepageURL https://github.com/knutkirkhorn/dark-facebook-messenger-theme
// @supportURL https://github.com/knutkirkhorn/dark-facebook-messenger-theme/issues
// @updateURL https://raw.githubusercontent.com/knutkirkhorn/dark-facebook-messenger-theme/main/favicon-replacer.js
// @match http://www.facebook.com/*
// @match https://www.facebook.com/*
// @match http://www.messenger.com/*
// @match https://www.messenger.com/*
// ==/UserScript==
// Adds a new <link> html element to override the current favicon
function replaceFavicon(url) {
const iconElement = document.createElement('link');
iconElement.rel = 'icon';
iconElement.href = url;
document.head.appendChild(iconElement);
}
// Check which favicon to change to
if (window.location.host === 'www.facebook.com') {
replaceFavicon('https://raw.githubusercontent.com/knutkirkhorn/dark-facebook-messenger-theme/main/media/fb.ico');
} else if (window.location.host === 'www.messenger.com') {
replaceFavicon('https://raw.githubusercontent.com/knutkirkhorn/dark-facebook-messenger-theme/main/media/messenger.ico');
}