<commit_before>let userToken = null;
let notificationsEnabled = true;
let loggingEnabled = false;
const DISCORD_GATEWAY_ENDPOINT = 'wss://gateway.discord.gg/?v=6&encoding=json';
const DEEZER_HOSTNAME = 'www.deezer.com';
const ICON_URL = 'discord48.png';

const OS = navigator.platform;
const BROWSER = 'Chrome';
const EXTENSION_NAME = 'Deezer Discord Integration';

const DELAY_CHECK_TABS = 2000;
const DELAY_CLOSE_WS = 180000;
const TITLE_SEPARATOR = ' - ';

let ws;
let currentDiscordStatus = null;
let currentPlayingTab = null;
let checkTabsTimer;
let heartbeatTimer;
let closeWsTimer;
let lastSeq = null;

const log = (message, force = false) => {
	if (loggingEnabled || force) {
		console.log(message);
	}
};
/* Send notification */
const notify = (message, callback = null) => {
	if (notificationsEnabled) {
			chrome.notifications.create({
				type: 'basic',
				iconUrl: ICON_URL,
				title: EXTENSION_NAME,
				message: message,
				isClickable: callback !== null,
			}, (notifId) => {
				if (callback !== undefined) {
					let notifCallback = (nid) => {
						if (nid === notifId) {
							callback();
						}
					};
					chrome.notifications.onClicked.addListener(notifCallback);
					chrome.notifications.onClosed.removeListener(notifCallback);
				}
			});
			log(`new notification '${message}'`);
	}
};

const cleanTitleRegexp = new RegExp(TITLE_SEPARATOR + 'Deezer(?=' + TITLE_SEPARATOR + ')', 'g');
const formatTabTitle = (title) => {
	const splitTitle = title.split(TITLE_SEPARATOR);
	if (splitTitle.length === 3) {
		return splitTitle[1] + TITLE_SEPARATOR + splitTitle[0] + TITLE_SEPARATOR + splitTitle[2];
	} else {
		return title.replace(cleanTitleRegexp, '');<commit_msg>Fix error when notify callback is not function<commit_after>let userToken = <PASSWORD>;
let notificationsEnabled = true;
let loggingEnabled = false;
const DISCORD_GATEWAY_ENDPOINT = 'wss://gateway.discord.gg/?v=6&encoding=json';
const DEEZER_HOSTNAME = 'www.deezer.com';
const ICON_URL = 'discord48.png';

const OS = navigator.platform;
const BROWSER = 'Chrome';
const EXTENSION_NAME = 'Deezer Discord Integration';

const DELAY_CHECK_TABS = 2000;
const DELAY_CLOSE_WS = 180000;
const TITLE_SEPARATOR = ' - ';

let ws;
let currentDiscordStatus = null;
let currentPlayingTab = null;
let checkTabsTimer;
let heartbeatTimer;
let closeWsTimer;
let lastSeq = null;

const log = (message, force = false) => {
	if (loggingEnabled || force) {
		console.log(message);
	}
};
/* Send notification */
const notify = (message, callback) => {
	let callbackIsFunction = typeof callback === 'function';
	if (notificationsEnabled) {
			chrome.notifications.create({
				type: 'basic',
				iconUrl: ICON_URL,
				title: EXTENSION_NAME,
				message: message,
				isClickable: callbackIsFunction,
			}, (notifId) => {
				if (callbackIsFunction) {
					let notifCallback = (nid) => {
						if (nid === notifId) {
							callback();
						}
					};
					chrome.notifications.onClicked.addListener(notifCallback);
					chrome.notifications.onClosed.removeListener(notifCallback);
				}
			});
			log(`new notification '${message}'`);
	}
};

const cleanTitleRegexp = new RegExp(TITLE_SEPARATOR + 'Deezer(?=' + TITLE_SEPARATOR + ')', 'g');
const formatTabTitle = (title) => {
	const splitTitle = title.split(TITLE_SEPARATOR);
	if (splitTitle.length === 3) {
		return splitTitle[1] + TITLE_SEPARATOR + splitTitle[0] + TITLE_SEPARATOR + splitTitle[2];
	} else {
		return title.replace(cleanTitleRegexp, '');
{'fraction_non_alphanumeric': 0.13525179856115108, 'fraction_numerical': 0.009784172661870504, 'mean_word_length': 4.465408805031447, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1943818', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1174, 'n_words': 259}