Skip to content

Instantly share code, notes, and snippets.

@jpigla
Last active February 17, 2023 09:02
Show Gist options
  • Save jpigla/52dc2b6750c85b2dcba5d4ad2cbe1f34 to your computer and use it in GitHub Desktop.
Save jpigla/52dc2b6750c85b2dcba5d4ad2cbe1f34 to your computer and use it in GitHub Desktop.
Boost for Arc Browser (https://arc.net/) - "SERP Result Hightlighter" (Website: "www.google.com")
/* This runs after a web page loads */
(function() {
const options = { "computerbild.de": "#ee5253", "autobild.de": "#2980b9" }
if (options) {
const domains = Object.keys(options);
console.log(domains)
const searchResultsTopStories = document.querySelectorAll("div.MkXWrd");
const searchResults = document.querySelectorAll("div.g");
searchResultsTopStories.forEach(function(result) {
const resultLink = result.querySelector("a");
const resultHeading = result.querySelector(".mCBkyc");
const resultUrl = resultLink.href;
if (resultLink) {
domains.forEach(function(domain) {
if (resultUrl.indexOf(domain) !== -1) {
//result.classList.add("highlighted-topstory-result");
resultHeading.classList.add("mark");
result.style.outlineColor = options[domain];
}
});
}
});
searchResults.forEach(function(result) {
const resultLink = result.querySelector("a");
const resultHeading = result.querySelector("h3");
const resultUrl = resultLink.href;
if (resultLink) {
domains.forEach(function(domain) {
if (resultUrl.indexOf(domain) !== -1) {
//result.classList.add("highlighted-result");
resultHeading.classList.add("mark");
result.style.outlineColor = options[domain];
}
});
}
});
}
})();
/* This is injected after a web page loads */
.highlighted-result {
outline-width: 2px;
outline-style: outset;
outline-offset: 15px;
animation: linear fadeIn .3s 10;
}
.highlighted-topstory-result {
outline-width: 2px;
outline-style: outset;
outline-offset: 5px;
animation: linear fadeIn .3s 3;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.mark {
margin: 0 -0.4em;
padding: 0.1em 0.4em;
border-radius: 0.8em 0.3em;
background: transparent;
background-image: linear-gradient(
to right,
rgba(255, 225, 0, 0.1),
rgba(255, 225, 0, 0.7) 4%,
rgba(255, 225, 0, 0.3)
);
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
animation: linear fadeIn .6s 3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment