Skip to content

Commit ffd3391

Browse files
authored
Merge pull request #31 from lnoss/0.0.7
refactor: trying again to use specifc selectors on both viewports
2 parents 9622513 + efde39a commit ffd3391

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

contents/no-search-results-translation.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,23 @@ const cleanResult = (resultDiv: HTMLDivElement): Promise<void> => {
257257
// Main function to initialize the translation cleaner
258258
const initializeTranslationCleaner = async () => {
259259
/*
260-
- #rso div.wHYlTd.Ww4FFb.vt6azd.tF2Cxc.asEBEc : normal results (at the left of the page when right sidebar);
261-
- #rhs div.qXbDwb : knowledge panel right sidebar (at the right of the page)
262-
- #rhs div.xGj8Mb : classic right sidebar with Wikipedia snippets;
260+
- #rso div.MjjYud : normal results lines sometimes improved (accordion or video results) on both viewports;
261+
- #rhs : right sidebar (desktop only);
262+
- #rhs div.qXbDwb : knowledge panel right sidebar (at the right of the page)
263+
- #rhs div.xGj8Mb : classic right sidebar with Wikipedia-like snippets;
264+
Same with #rso div.qXbDwb and #rso div.xGj8Mb but only on mobile (one column).
263265
There is sometimes a top knowledge panel, but it is not affected by the translation for now.
264266
*/
265-
const resultDivs : NodeListOf<HTMLDivElement> = document.querySelectorAll<HTMLDivElement>('#rso div.wHYlTd.Ww4FFb.vt6azd.tF2Cxc.asEBEc, #rhs div.xGj8Mb, #rhs div.qXbDwb');
266-
await Promise.all(
267-
Array.from(resultDivs).map(resultDiv => cleanResult(resultDiv))
268-
);
267+
const selectors = [
268+
'#rso div.MjjYud',
269+
'#rso div.xGj8Mb',
270+
'#rso div.qXbDwb',
271+
'#rhs div.xGj8Mb',
272+
'#rhs div.qXbDwb',
273+
].join(', ');
274+
275+
const resultDivs = document.querySelectorAll<HTMLDivElement>(selectors);
276+
await Promise.all(Array.from(resultDivs).map(cleanResult));
269277
};
270278

271279
// Event listener to run the cleaner when the DOM is fully loaded

0 commit comments

Comments
 (0)