Skip to content

Instantly share code, notes, and snippets.

@amr3k
Created January 20, 2025 09:19
Show Gist options
  • Save amr3k/4676e4f720ef82f2da4bcddce0c637df to your computer and use it in GitHub Desktop.
Save amr3k/4676e4f720ef82f2da4bcddce0c637df to your computer and use it in GitHub Desktop.
Geekbench average score (User script)
// ==UserScript==
// @name Geekbench average score
// @namespace http://tampermonkey.net/
// @version 2025-01-20
// @description Display the average score in each browser page
// @author You
// @match https://browser.geekbench.com/search*
// @icon https://www.google.com/s2/favicons?sz=64&domain=geekbench.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
var _tableLength = Array.from(document.querySelectorAll('.row>div:nth-of-type(4) .list-col-text-score'))?.length || 1;
var _averageSingle = Math.round(Array.from(document.querySelectorAll('.row>div:nth-of-type(4) .list-col-text-score')).reduce((acc, cur, init) => acc + parseInt(cur.innerText), 0) / _tableLength);
var _averageMulti = Math.round(Array.from(document.querySelectorAll('.row>div:nth-of-type(5) .list-col-text-score')).reduce((acc, cur, init) => acc + parseInt(cur.innerText), 0) / _tableLength);
if (typeof _averageSingle === 'number' && _averageSingle !== NaN && _averageSingle !== Infinity && _averageSingle > 0 && typeof _averageMulti === 'number' && _averageMulti !== NaN && _averageMulti !== Infinity && _averageMulti > 0) {
var _statisticsElm = document.createElement('div');
_statisticsElm.classList.add('card', 'bg-info', 'text-white', 'justify-self-center', 'w-auto');
_statisticsElm.setAttribute('style', 'width:fit-content !important; margin: 1rem auto; padding: 1rem;');
_statisticsElm.innerHTML = `
<div class="row justify-content-center align-items-center">
<div class="px-4">
<h3 class="text-center">Avg single core</h3>
<p class="text-center display-4">${_averageSingle}</p>
</div>
<div class="px-4">
<h3 class="text-center">Avg multi core</h3>
<p class="text-center display-4">${_averageMulti}</p>
</div>
</div>
`;
var _table = document.querySelector('html body div#wrap.container div.row div.col-12 div.container div.row div.col-12.col-lg-9');
_table.prepend(_statisticsElm);
// Copying pagination element to the top for easier navigation
var _paginationContainer = document.createElement('div');
_paginationContainer.innerHTML = document.querySelector('.pagination-container')?.innerHTML ?? '';
_table.prepend(_paginationContainer);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment