I originally wrote this code to some other website.
Tweaked a bit to use on amazon.com as well.
This (most of the time) finds the CPU name in the page and creates a direct link to cpubenchmark.net
so you can see in-depth information about the CPU.
Right now I'm using this with arc's boost feature.
If amazon makes changes on their web page, it might not work or there might be layout related issues.
Once the page is loaded hit the Shift+Control+C
to activate it.
const regexIntel =
/(intel core|intel|core|xeon|pentium)?\s(i|e|x|j)(3|5|7|9|)?(\s|-|)\d{3,6}(\w)?/gi;
// Intel Celeron
const regexCeleron = /celeron\s(\w)?\d{3,6}(\w)?/gi;
// AMD
const regexAMD =
/(amd\s)?((ryzen™?|ruben)|athlon|a|e|fx)(\s|-)?\d{1,5}(\spro)?(\s|-)?\d{4}\w{0,2}/gi;
const className = "cpu-lookup-link";
function markCPUs() {
if (document.getElementsByClassName(className).length) {
return;
}
const benchmarkLink = "https://www.cpubenchmark.net/cpu.php?cpu=";
const links = document.getElementsByTagName("a");
[...links].forEach((link) => {
const text = link.innerText;
let cpu = "";
if (regexCeleron.test(text)) {
cpu = text.match(regexCeleron);
} else if (regexIntel.test(text)) {
cpu = text.match(regexIntel);
} else if (regexAMD.test(text)) {
cpu = text.match(regexAMD);
}
if (cpu) {
cpu = `${cpu}`.trim();
const parentElement = link.parentElement;
const lookupLink = document.createElement("a");
lookupLink.href = `${benchmarkLink}${cpu}`.replace("™", "");
lookupLink.target = "_blank";
lookupLink.innerText = "🔍";
lookupLink.title = "Lookup CPU: " + cpu;
// CUSTOM CODE
parentElement.style.position = "relative";
lookupLink.className = className;
lookupLink.style.position = "absolute";
lookupLink.style.right = "0px";
lookupLink.style.bottom = "0";
lookupLink.style.backgroundColor = "wheat";
lookupLink.style.padding = "3px";
lookupLink.style.borderRadius = "50%";
lookupLink.style.filter = "unset";
// Add Search Link
parentElement.insertBefore(lookupLink, link);
// Add Text
// link.parentElement.insertBefore(document.createTextNode(`${cpu}`.trim()), link);
}
});
}
function removeCPULinks() {
const links = document.getElementsByClassName(className);
[...links].forEach((link) => {
link.remove();
});
}
document.onkeydown = function (e) {
if (e.ctrlKey && e.shiftKey && e.key === "C") {
markCPUs();
} else if (e.ctrlKey && e.shiftKey && e.key === "X") {
removeCPULinks();
}
};
arc
, boost
, cpu-benchmark
, user-scripts