{"size": 1074, "ext": "js", "max_stars_repo_path": "src/scripts/service.js", "max_stars_repo_name": "Elliot67/page_swapper", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/scripts/service.js", "max_issues_repo_name": "Elliot67/page_swapper", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/scripts/service.js", "max_forks_repo_name": "Elliot67/page_swapper", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.85, "max_line_length": 93, "alphanum_fraction": 0.6648044693}
export function redirectTo(newUrl) {
	chrome.tabs.update({ url: newUrl });
}

export function getTabInfo() {
	return new Promise((resolve, reject) => {
		chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
			resolve(tabs[0]);
		});
	});
}

export function getGroupsFromSettings() {
	return new Promise((resolve, reject) => {
		chrome.storage.local.get('groups-v1', (settings) => {
			const groups = settings && settings['groups-v1']?.length > 0 ? settings['groups-v1'] : [];
			resolve(groups);
		});
	});
}

export async function setGroupsToSettings(newGroups) {
	return new Promise((resolve, reject) => {
		chrome.storage.local.set({ 'groups-v1': newGroups }, () => resolve());
	});
}

export function clearSettings() {
	return new Promise((resolve, reject) => {
		chrome.storage.local.clear(() => resolve());
	});
}

export function sleep(seconds) {
	return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
}

export function generateUniqueId() {
	return (Date.now().toString(36) + Math.random().toString(36).substr(2, 5)).toUpperCase();
}