Got the source tracking correctly.
This commit is contained in:
parent
e43d9b9987
commit
55c59178f4
|
|
@ -318,10 +318,28 @@
|
|||
|
||||
console.log(`Found ${rows.length} rows to process`);
|
||||
|
||||
let currentSource = "Keyword Ideas"; // Default source
|
||||
|
||||
for (const row of rows) {
|
||||
try {
|
||||
// Check if this is a header row
|
||||
if (row.classList.contains('group-header')) {
|
||||
const headerText = row.querySelector('ess-cell')?.textContent.trim();
|
||||
if (headerText === 'Keywords you provided') {
|
||||
currentSource = "Keyword Provided";
|
||||
console.log('Switching to Keywords you provided section');
|
||||
} else if (headerText === 'Keyword ideas') {
|
||||
currentSource = "Keyword Ideas";
|
||||
console.log('Switching to Keyword ideas section');
|
||||
}
|
||||
continue; // Skip processing this row as it's a header
|
||||
}
|
||||
|
||||
// Get keyword text
|
||||
const keywordText = row.querySelector('keyword-text')?.textContent.trim();
|
||||
if (!keywordText || keywordText.includes('...')) {
|
||||
continue; // Skip empty or truncated keywords
|
||||
}
|
||||
|
||||
// Get search volume - try multiple selectors
|
||||
let volumeText = null;
|
||||
|
|
@ -346,23 +364,11 @@
|
|||
// Format the volume (remove commas)
|
||||
volumeText = formatSearchVolume(volumeText);
|
||||
|
||||
// Get source - check if it's a provided keyword
|
||||
let source = "Keyword Ideas";
|
||||
if (row.querySelector('.provided-keyword') ||
|
||||
row.matches('.provided-keyword') ||
|
||||
row.classList.contains('provided-keyword') ||
|
||||
row.querySelector('[title*="Keyword you provided"]') ||
|
||||
row.querySelector('[data-column-id="SOURCE"][title*="provided"]')) {
|
||||
source = "Keyword you provided";
|
||||
}
|
||||
|
||||
if (keywordText && !keywordText.includes('...')) {
|
||||
sections.push({
|
||||
keyword: keywordText,
|
||||
volume: volumeText,
|
||||
source: source
|
||||
});
|
||||
}
|
||||
sections.push({
|
||||
keyword: keywordText,
|
||||
volume: volumeText,
|
||||
source: currentSource
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error processing row:', error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue