Skip to content

Instantly share code, notes, and snippets.

@idpaterson
Last active April 8, 2023 05:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idpaterson/d2eb82b358ca0ebb9a43e6318ab3a29e to your computer and use it in GitHub Desktop.
Save idpaterson/d2eb82b358ca0ebb9a43e6318ab3a29e to your computer and use it in GitHub Desktop.
Assists in finding the gift-bearing hummingbirds at topcashback.com

TopCashback Bird Watcher

Always on the lookout for the gift-bearing hummingbirds that inhabit TopCashback.com, this script grays the browser tab icon for any retailer page that does not feature a hummingbird. Once a bird is spotted the corresponding hummingbird tab icon returns to full color.

hummingbird-found

Useful for exploring a large number of habitats at once. Open-to-background-tab many retailers then wait a few seconds to see if any birds pop up in the tab icons. Simply close all tabs if your budding hobby as digital ornithologist is unfruitful.

Installation

For use with a userscript browser extension like Greasemonkey (Firefox) or Tampermonkey (Chrome). With one of these browser extensions installed you can install the userscript by clicking below:

Usage

Visit TopCashback after installing. Hummingbirds are attracted to the bright colors used in the "cash back giveaway" banners; you will probably not find any outside of giveaway offerings. Since the hummingbird is easy to see with your human eyes when viewing an individual retailer, this script is most helpful when you open multiple tabs at once to different retailers; employ the bird watcher to avoid having to hunt through all the tabs yourself.

Cmd+click or Ctrl+click or a middle mouse button click on a link should all open a link in a background tab.

Configuration

At this time there is no customization available for the userscript. It clicks the birb. Maybe you don't want that – in which case you can complain or just remove the line that very obviously does the clicky click.

Updates

This userscript is configured to support automatic updates when changes are published. Your userscript manager may prompt you to install updates when available; refer to this gist for information about the changes in each version.

Scope

This script is only activated on the following pages of topcashback.com:

  • https://www.topcashback.com/*/

Well, that's a lot of pages. Fortunately, the bird watching only happens on retailer pages so you will not see confusing gray tab icons on other pages. All script activity is performed locally in your web browser based on the data available on the TopCashback page that you are viewing; the userscript does not load or contact any external systems.

History

0.1.x - February 2018

Documentation, automatic updating, and non-retailer page avoidance.

0.0.x - January 2018

It watches for birds, it clicks birds, and it does the tab icon color thing.

License

MIT License

Copyright (c) 2018 Ian Paterson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// ==UserScript==
// @name TopCashback Bird Watcher
// @description Observe the gift-bearing hummingbirds that inhabit TopCashback.com
// @version 0.1.3
// @author Ian Paterson
// @namespace http://idpaterson.github.io/
// @copyright Copyright (c) 2018 Ian Paterson
// @license MIT - https://tldrlegal.com/license/mit-license
// @match https://www.topcashback.com/*/
// @grant none
// @require https://cdn.jsdelivr.net/npm/grayscale-favicon@1.0.0/grayscale-favicon.js
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @require https://gist.githubusercontent.com/kepkin/ff99090c410ab1b5c8fa/raw/a1e229b38cb6eb169556ae9b5e751e5c81d59929/waitForKeyElements.js
// @run-at document-start
// @updateURL https://gist.github.com/idpaterson/d2eb82b358ca0ebb9a43e6318ab3a29e/raw/topcashback-bird-watcher.meta.js
// @downloadURL https://gist.github.com/idpaterson/d2eb82b358ca0ebb9a43e6318ab3a29e/raw/topcashback-bird-watcher.user.js
// ==/UserScript==
// ==UserScript==
// @name TopCashback Bird Watcher
// @description Observe the gift-bearing hummingbirds that inhabit TopCashback.com
// @version 0.1.3
// @author Ian Paterson
// @namespace http://idpaterson.github.io/
// @copyright Copyright (c) 2018 Ian Paterson
// @license MIT - https://tldrlegal.com/license/mit-license
// @match https://www.topcashback.com/*/
// @grant none
// @require https://cdn.jsdelivr.net/npm/grayscale-favicon@1.0.0/grayscale-favicon.js
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @require https://gist.githubusercontent.com/kepkin/ff99090c410ab1b5c8fa/raw/a1e229b38cb6eb169556ae9b5e751e5c81d59929/waitForKeyElements.js
// @run-at document-start
// @updateURL https://gist.github.com/idpaterson/d2eb82b358ca0ebb9a43e6318ab3a29e/raw/topcashback-bird-watcher.meta.js
// @downloadURL https://gist.github.com/idpaterson/d2eb82b358ca0ebb9a43e6318ab3a29e/raw/topcashback-bird-watcher.user.js
// ==/UserScript==
(function() {
'use strict';
// Grays the tab icon and watches for birds
function birdwatch() {
// Gray out the icon
GrayscaleFavicon.icon('/favicon.ico');
// Wait for the hummingbird
waitForKeyElements('#birdClick:visible', celebrate, true);
}
// Birdwatch only on a retailer page
function birdwatchIfNecessary() {
if ($('.gecko-primary .gecko-single-container:first-child div[id*=merchantPnl]').length > 0) {
birdwatch();
}
}
// Found a hummingbird, reset to full color icon and click it!
function celebrate($birb) {
GrayscaleFavicon.reset();
setTimeout(function() { $birb.click(); }, 1000);
}
// I think this is usually not a real gecko
waitForKeyElements('.gecko-primary', birdwatchIfNecessary, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment