Complete overhaul of code structure and relevant files (#639)
This commit is contained in:
25
src/Disp/TabTitle/FavIcon.js
Normal file
25
src/Disp/TabTitle/FavIcon.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { CacheSpawnedGoldenShimmer } from '../../Cache/VariablesAndData';
|
||||
import { CMOptions } from '../../Config/VariablesAndData';
|
||||
import { LastGoldenCookieState } from '../../Main/VariablesAndData';
|
||||
|
||||
/**
|
||||
* This function creates the Favicon, it is called by CM.Main.DelayInit()
|
||||
*/
|
||||
export function CreateFavicon() {
|
||||
const Favicon = document.createElement('link');
|
||||
Favicon.id = 'CMFavicon';
|
||||
Favicon.rel = 'shortcut icon';
|
||||
Favicon.href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico';
|
||||
document.getElementsByTagName('head')[0].appendChild(Favicon);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function updates the Favicon depending on whether a Golden Cookie has spawned
|
||||
* By relying on CM.Cache.spawnedGoldenShimmer it only changes for non-user spawned cookie
|
||||
*/
|
||||
export function UpdateFavicon() {
|
||||
if (CMOptions.Favicon === 1 && LastGoldenCookieState > 0) {
|
||||
if (CacheSpawnedGoldenShimmer.wrath) l('CMFavicon').href = 'https://aktanusa.github.io/CookieMonster/favicon/wrathCookie.ico';
|
||||
else l('CMFavicon').href = 'https://aktanusa.github.io/CookieMonster/favicon/goldenCookie.ico';
|
||||
} else l('CMFavicon').href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico';
|
||||
}
|
||||
Reference in New Issue
Block a user