Last active
December 1, 2022 13:01
-
-
Save dallasread/4f8f10689f192be9fc8582ebae69c50e to your computer and use it in GitHub Desktop.
Find a keyword on a page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name KeywordFinder | |
// @version 1 | |
// @grant none | |
// @match https://news.ycombinator.com/* | |
// ==/UserScript== | |
(function(keyword) { | |
const counter = document.createElement('p') | |
counter.style.position = 'fixed' | |
counter.style.top = '0' | |
counter.style.right = '0' | |
counter.style.backgroundColor = '#1A5EC6' | |
counter.style.color = '#fff' | |
counter.style.fontSize = '18px' | |
counter.style.padding = '9px' | |
counter.style.margin = '0' | |
const occurrences = document.body.innerHTML.match(new RegExp(keyword, 'gi')) | |
if (occurrences) { | |
counter.innerText = `${keyword}: ${occurrences.length}` | |
document.body.appendChild(counter) | |
} | |
})('dnsimple') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment