Skip to content

Commit

Permalink
feat(google): add support for Google Q&A section (#473)
Browse files Browse the repository at this point in the history
resolve #437

* Add support to Goggle Q&A section on Desktop

* Add support to Goggle Q&A section on Mobile

* Fix background issue for blocked elements on Q&A

* Fix issue where Q&A body would load after the rule
  • Loading branch information
aug-dev committed May 26, 2024
1 parent 7c7211b commit 2d30bc5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/scripts/search-engines/google-desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,28 @@ const desktopSerpHandlers: Record<string, SerpHandler> = {
title: (root) => root.querySelector("h3")?.textContent ?? null,
...regularEntryHandler,
},
// Questions & answers
{
target: ".Hb5Kgc > .m9wSUc",
level: ".Tpb3kb > .BmkBMc",
url: "a",
title: ".RqlTSb",
actionTarget: ".m9wSUc",
actionPosition: "afterend",
actionStyle: (actionRoot) => {
actionRoot.className = css({
...desktopActionStyle,
display: "inline-block",
fontSize: "14px",
paddingLeft: "4px",
});
actionRoot.previousElementSibling?.classList.add(
css({
display: "inline-block !important",
}),
);
},
},
// Quote in the News
{
target: ".UaDxmd > .F4CzCf",
Expand Down
27 changes: 26 additions & 1 deletion src/scripts/search-engines/google-mobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const mobileSerpHandlers: Record<string, SerpHandler> = {
"": handleSerp({
globalStyle: {
...mobileGlobalStyle,
"[data-ub-blocked] .ZINbbc, [data-ub-highlight] .ZINbbc, [data-ub-blocked] .D9l01, [data-ub-highlight] .D9l01":
"[data-ub-blocked] .ZINbbc, [data-ub-highlight] .ZINbbc, [data-ub-blocked] .D9l01, [data-ub-highlight] .D9l01, .BmkBMc g-inner-card":
{
backgroundColor: "transparent !important",
},
Expand Down Expand Up @@ -238,6 +238,31 @@ const mobileSerpHandlers: Record<string, SerpHandler> = {
actionTarget: "",
actionStyle: mobileRegularActionStyle,
},
// Questions & answers
{
target: ".Hb5Kgc > .m9wSUc",
level: ".Tpb3kb > .BmkBMc",
url: "a",
title: ".RqlTSb",
actionTarget: ".m9wSUc",
actionPosition: "afterend",
actionStyle: (actionRoot) => {
actionRoot.className = css({
"&::before": {
content: '" · "',
},
display: "inline-block",
fontSize: "14px",
paddingLeft: "4px",
...iOSButtonStyle,
});
actionRoot.previousElementSibling?.classList.add(
css({
display: "inline-block !important",
}),
);
},
},
],
pagerHandlers: [
// iOS
Expand Down

0 comments on commit 2d30bc5

Please sign in to comment.