Skip to content

Commit

Permalink
Merge pull request #116 from pistom/feat/115-handle-new-google-serp-r…
Browse files Browse the repository at this point in the history
…edesign

feat: check for dirrect url in results
  • Loading branch information
pistom authored Feb 1, 2020
2 parents 46128bd + bc6af4f commit ba3460b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion public/manifests/chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Highlight or Hide Search Engine Results",
"short_name": "HoHSER",
"version": "3.3.3",
"version": "3.4.0",
"description": "Filter search engine results. Block unwanted results and highlight the favorite ones. For Google and other popular search engines.",
"icons": {
"19": "images/hohser-19.png",
Expand Down
2 changes: 1 addition & 1 deletion public/manifests/firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Highlight or Hide Search Engine Results",
"short_name": "HoHSER",
"version": "3.3.3",
"version": "3.4.0",
"developer": {
"name": "Tomasz Pisarek",
"url": "https://github.com/pistom"
Expand Down
3 changes: 2 additions & 1 deletion src/config/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { SearchEngineConfig } from '../types';
export const google: SearchEngineConfig = {
resultSelector: '.g, .mnr-c, .rg_bx, .rg_di, .rg_el, .ZINbbc, .JP1Bwd',
domainSelector: '.TbwUpd, .dTe0Ie, .xQ82C, .e8fRJf, .FnqxG, .BNeawe, .pDavDe',
observerSelector: '#rcnt, #cnt, #rg, #main'
observerSelector: '#rcnt, #cnt, #rg, #main',
resultUrlSelector: '.r > a'
};
12 changes: 8 additions & 4 deletions src/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@ function processResult (r: Element, domainList: any, options: any, processResult
try {
const result = r as HTMLElement;
result.classList.add('hohser_result');
const domain = result.querySelector(
searchEngineConfig.domainSelector
) as HTMLElement;
const domain = searchEngineConfig.resultUrlSelector &&
result.querySelector(
searchEngineConfig.resultUrlSelector
) as HTMLAnchorElement ||
result.querySelector(
searchEngineConfig.domainSelector
) as HTMLElement;
// Skip result if no domain selector
if (!domain) return displayStyle;

const url = domain.innerText;
const url = (domain as HTMLAnchorElement).href || (domain as HTMLElement).innerText;
if (!url) {
throw new Error("No domain info");
}
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface SearchEngineConfig {
domainSelector: string;
observerSelector: string;
ajaxResults?: boolean;
resultUrlSelector?: string;
}

export interface StoreState {
Expand Down

0 comments on commit ba3460b

Please sign in to comment.