<commit_before>/* globals select, empty, domify, parseHTML, OptionsSync, setTimeoutUntilVisible, elementReady, postForm, delegate */

let options;
let notifications;

class Notifications {
	constructor() {
		try {
			// Firefox bug requires location.origin
			// https://github.com/sindresorhus/refined-github/issues/489
			const url = options.participating ? '/notifications/participating' : '/notifications';
			this.dom = fetch(location.origin + url, {
				credentials: 'include'
			}).then(r => r.text()).then(parseHTML);
		} catch (err) {/* Ignore network failures */}
	}

	async getList() {
		if (!this.list) {
			this.list = select.all('.notifications-list .boxed-group, .js-active-navigation-container', await this.dom);

			// Change tooltip direction
			for (const group of this.list) {
				for (const {classList} of select.all('.tooltipped-s', group)) {
					classList.replace('tooltipped-s', 'tooltipped-n');
				}
			}
		}
		return this.list;
	}
}

function getRefinedGitHubUnreadCount() {
	const element = select('[data-rgh-unread]');
	if (!element) {
		return 0;
	}
	return Number(element.dataset.rghUnread);
}

// Is the dropdown open? Is it opening?
function isOpen(el) {
	return select.exists('.NPG-opener[aria-expanded="true"], .NPG-loading', el);
}

async function updateUnreadCount() {
	const latestStatusEl = select('.notification-indicator .mail-status', await notifications.dom);
	const latestCount = select([
		'.notification-center .selected .count', // Classic
		'.js-notification-inboxes .selected .count' // Beta
	], await notifications.dom).textContent;
	const rghCount = getRefinedGitHubUnreadCount();

	for (const statusEl of select.all('.notification-indicator .mail-status')) {
		if (options.previewCount && statusEl.textContent !== latestCount) {
			statusEl.textContent = Number(latestCount) + rghCount || ''; // Don't show 0
		}
		statusEl.classList.toggle('unread', rghCount || latestStatusEl.classList.contains('unread'));<commit_msg>Always use the beta version<commit_after>/* globals select, empty, domify, parseHTML, OptionsSync, setTimeoutUntilVisible, elementReady, postForm, delegate */

let options;
let notifications;

class Notifications {
	constructor() {
		try {
			// Firefox bug requires location.origin
			// https://github.com/sindresorhus/refined-github/issues/489
			const url = new URL('notifications/beta', location.origin);
			if (options.participating) {
				url.searchParams.set('query', 'is:unread reason:participating');
			} else {
				url.searchParams.set('query', 'is:unread');
			}

			this.dom = fetch(url).then(r => r.text()).then(parseHTML);
		} catch (err) {/* Ignore network failures */}
	}

	async getList() {
		if (!this.list) {
			this.list = select.all('.notifications-list .boxed-group, .js-active-navigation-container', await this.dom);

			// Change tooltip direction
			for (const group of this.list) {
				for (const {classList} of select.all('.tooltipped-s', group)) {
					classList.replace('tooltipped-s', 'tooltipped-n');
				}
			}
		}
		return this.list;
	}
}

function getRefinedGitHubUnreadCount() {
	const element = select('[data-rgh-unread]');
	if (!element) {
		return 0;
	}
	return Number(element.dataset.rghUnread);
}

// Is the dropdown open? Is it opening?
function isOpen(el) {
	return select.exists('.NPG-opener[aria-expanded="true"], .NPG-loading', el);
}

async function updateUnreadCount() {
	const latestStatusEl = select('.notification-indicator .mail-status', await notifications.dom);
	const latestCount = select('.js-notification-inboxes .selected .count', await notifications.dom).textContent;
	const rghCount = getRefinedGitHubUnreadCount();

	for (const statusEl of select.all('.notification-indicator .mail-status')) {
		if (options.previewCount && statusEl.textContent !== latestCount) {
			statusEl.textContent = Number(latestCount) + rghCount || ''; // Don't show 0
		}
		statusEl.classList.toggle('unread', rghCount || latestStatusEl.classList.contains('unread'));
{'fraction_non_alphanumeric': 0.14982403217697335, 'fraction_numerical': 0.002513826043237808, 'mean_word_length': 4.3053333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '4216781', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1232, 'n_words': 275}