chore: checkpoint current working state

This commit is contained in:
2026-02-12 17:40:52 +01:00
parent 585e5d5455
commit bbfa93a586
6 changed files with 206 additions and 44 deletions

View File

@@ -17,6 +17,7 @@ const SEARCH_RESULTS_PATH_PREFIX = '/search';
const FEED_HOME_PATHS = ['/', '/home.php'];
const sessionSearchRecordedUrls = new Set();
const sessionSearchInfoCache = new Map();
let profileSelectionNoticeShown = false;
function isOnSearchResultsPage() {
try {
@@ -49,6 +50,19 @@ function maybeRedirectPageReelsToMain() {
if (typeof pathname !== 'string') {
return false;
}
if (pathname.toLowerCase() === '/profile.php') {
const params = new URLSearchParams(location.search || '');
const profileId = params.get('id');
const sk = params.get('sk');
if (profileId && sk && sk.toLowerCase().startsWith('reel')) {
const targetUrl = `${location.origin}/profile.php?id=${encodeURIComponent(profileId)}`;
if (location.href !== targetUrl) {
location.replace(targetUrl);
return true;
}
return false;
}
}
const match = pathname.match(/^\/([^/]+)\/reels\/?$/i);
if (!match) {
return false;
@@ -513,6 +527,10 @@ async function getProfileNumber() {
console.warn('[FB Tracker] Failed to resolve profile number from backend:', error);
}
if (!profileSelectionNoticeShown) {
profileSelectionNoticeShown = true;
showToast('Bitte zuerst ein Profil im Tracker auswählen.', 'error');
}
return null;
}

View File

@@ -112,6 +112,7 @@
<div class="section">
<label for="profileSelect">Aktuelles Profil:</label>
<select id="profileSelect">
<option value="">-- Profil wählen --</option>
<option value="1">Profil 1</option>
<option value="2">Profil 2</option>
<option value="3">Profil 3</option>

View File

@@ -2,6 +2,10 @@ const profileSelect = document.getElementById('profileSelect');
const statusEl = document.getElementById('status');
const debugToggle = document.getElementById('debugLoggingToggle');
function isValidProfileNumber(value) {
return Number.isInteger(value) && value >= 1 && value <= 5;
}
function apiFetch(url, options = {}) {
const config = {
...options,
@@ -61,7 +65,7 @@ function updateStatus(message, saved = false) {
async function initProfileSelect() {
const backendProfile = await fetchProfileState();
if (backendProfile) {
if (isValidProfileNumber(backendProfile)) {
profileSelect.value = String(backendProfile);
chrome.storage.sync.set({ profileNumber: backendProfile });
updateStatus(`Profil ${backendProfile} ausgewählt`);
@@ -69,9 +73,14 @@ async function initProfileSelect() {
}
chrome.storage.sync.get(['profileNumber'], (result) => {
const profileNumber = result.profileNumber || 1;
profileSelect.value = String(profileNumber);
updateStatus(`Profil ${profileNumber} ausgewählt (lokal)`);
const profileNumber = result.profileNumber;
if (isValidProfileNumber(profileNumber)) {
profileSelect.value = String(profileNumber);
updateStatus(`Profil ${profileNumber} ausgewählt (lokal)`);
return;
}
profileSelect.value = '';
updateStatus('Bitte zuerst ein Profil auswählen.');
});
}
@@ -101,6 +110,10 @@ function reloadFacebookTabs() {
document.getElementById('saveBtn').addEventListener('click', async () => {
const profileNumber = parseInt(profileSelect.value, 10);
if (!isValidProfileNumber(profileNumber)) {
updateStatus('Bitte zuerst ein Profil auswählen.');
return;
}
chrome.storage.sync.set({ profileNumber }, async () => {
updateStatus(`Profil ${profileNumber} gespeichert!`, true);