Last active
April 30, 2020 05:19
-
-
Save sergiosusa/b338edfacae4e70468e82698e1f242b8 to your computer and use it in GitHub Desktop.
Copy the games present on the famous bundle websites to the clipboard using a link injected on the 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 Games Bundle Extrator | |
// @namespace http://sergiosusa.com | |
// @version 0.7 | |
// @description Extract the name of the games in diferent bundles. | |
// @author Sergio Susa (sergio@sergiosusa.com) | |
// @match https://www.gogobundle.com/latest/bundles/* | |
// @match https://gogobundle.com/latest/bundles/* | |
// @match https://www.indiegala.com/* | |
// @match https://www.humblebundle.com/games/* | |
// @match https://www.fanatical.com/*/bundle/* | |
// @match http://dailyindiegame.com/* | |
// @match https://groupees.com/* | |
// @match https://cubicbundle.com/* | |
// @grant GM_setClipboard | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js | |
// ==/UserScript== | |
/***** CONSTANTS *****/ | |
const PAGE_GO_GO_BUNDLE = 'gogobundle.com/latest/bundles/'; | |
const PAGE_INDIE_GALA = 'www.indiegala.com'; | |
const PAGE_HUMBLE_BUNDLE = 'www.humblebundle.com/games/'; | |
const PAGE_FANATICAL = 'www.fanatical.com/en/bundle/'; | |
const PAGE_DAILY_INDIE_GAME = 'dailyindiegame.com'; | |
const PAGE_GROUPEES = 'groupees.com'; | |
const PAGE_CUBIC_BUNDLE = 'cubicbundle.com'; | |
(function() { | |
'use strict'; | |
$( document ).ready(function() { | |
var url = getCurrentUrl(); | |
insertGraphicElements(url); | |
}); | |
})(); | |
function insertGraphicElements(url) | |
{ | |
if (url.includes(PAGE_GO_GO_BUNDLE)){ | |
insertGoGoBundleGraphicElements(); | |
} else if (url.includes(PAGE_INDIE_GALA)){ | |
insertIndieGalaGraphicElements(); | |
} else if (url.includes(PAGE_HUMBLE_BUNDLE)){ | |
insertHumbleBundleGraphicElements(); | |
} else if (url.includes(PAGE_FANATICAL)){ | |
setTimeout( | |
insertFanaticalGraphicElements, 2000); | |
} else if (url.includes(PAGE_DAILY_INDIE_GAME)){ | |
insertDailyIndieGameGraphicElements(); | |
} else if (url.includes(PAGE_GROUPEES)){ | |
insertGroupeesGraphicElements(); | |
} else if (url.includes(PAGE_CUBIC_BUNDLE)){ | |
insertCubicBundleElements(); | |
} else { | |
// not support this site. | |
} | |
} | |
/*********************************************************** | |
* Cubic Bundle | |
**********************************************************/ | |
function insertCubicBundleElements() | |
{ | |
if (!isCubicBundlePage()) { | |
return; | |
} | |
var element = $('div.home-header div.row div.col-sm-4')[0]; | |
var anchor = document.createElement('a'); | |
anchor.innerHTML = '( Copy List Of Games )'; | |
anchor.href = '#'; | |
anchor.style = 'text-align: center;display: block;'; | |
anchor.onclick = startCubicBundle; | |
element.appendChild(anchor); | |
} | |
function isCubicBundlePage() | |
{ | |
if ($('form[method="post"]').size() > 1){ | |
return true; | |
} | |
return false; | |
} | |
function startCubicBundle() | |
{ | |
var titles = $('h3.card-title a'); | |
var listOfGames = []; | |
for(var x = 0; x < titles.length; x++) { | |
listOfGames.push(titles[x].innerHTML.trim()); | |
} | |
toClipboard(listOfGames.join('\n')); | |
} | |
/*********************************************************** | |
* Groupess | |
**********************************************************/ | |
function insertGroupeesGraphicElements() | |
{ | |
if (!isGroupeesPage()) { | |
return; | |
} | |
var element = $('div.tier-header')[0]; | |
var anchor = document.createElement('a'); | |
anchor.innerHTML = '( Copy List Of Games )'; | |
anchor.href = '#'; | |
anchor.style = 'text-align: center;display: block;'; | |
anchor.onclick = startGroupees; | |
insertBefore(anchor, element); | |
} | |
function isGroupeesPage() | |
{ | |
if ($('.buy-bundle').size() == 1){ | |
return true; | |
} | |
return false; | |
} | |
function startGroupees() | |
{ | |
var titles = $('div.product-info > h4'); | |
var listOfGames = []; | |
for(var x = 0; x < titles.length; x++) { | |
listOfGames.push(titles[x].innerHTML.trim()); | |
} | |
toClipboard(listOfGames.join('\n')); | |
} | |
/*********************************************************** | |
* Daily Indie Games | |
**********************************************************/ | |
function insertDailyIndieGameGraphicElements() | |
{ | |
if (!isDailyIndieGamePage()){ | |
return; | |
} | |
var element = $('#DIG2TableGray > tbody > tr > td > table:nth-child(2)')[0]; | |
var anchor = document.createElement('a'); | |
anchor.innerHTML = '( Copy List Of Games )'; | |
anchor.href = '#'; | |
anchor.style = 'text-align: center;display: block;'; | |
anchor.onclick = startDailyIndieGame; | |
insertAfter(anchor, element); | |
} | |
function startDailyIndieGame() | |
{ | |
var titles = $('div.DIG2-TitleOrange'); | |
var listOfGames = []; | |
for(var x = 0; x < titles.length; x++) { | |
listOfGames.push(titles[x].innerHTML.trim()); | |
} | |
toClipboard(listOfGames.join('\n')); | |
} | |
function isDailyIndieGamePage() | |
{ | |
if ($('input[type="image"]')[0].src === 'http://dailyindiegame.com/dig2-images/button-buy-paypal.png'){ | |
return true; | |
} | |
return false; | |
} | |
/*********************************************************** | |
* Fanatical | |
**********************************************************/ | |
function insertFanaticalGraphicElements() | |
{ | |
var element = document.getElementsByClassName('product-commerce-container')[0]; | |
var anchor = document.createElement('a'); | |
anchor.innerHTML = '( Copy List Of Games )'; | |
anchor.href = '#'; | |
anchor.style = 'text-align: center;'; | |
anchor.onclick = startFanaticalBundle; | |
insertAfter(anchor, element); | |
} | |
function startFanaticalBundle() | |
{ | |
var listOfGames = []; | |
var rows = document.getElementsByClassName('bundle-row'); | |
for(var x = 0; x < rows.length; x++) { | |
var textNode = rows[x].getElementsByTagName('div')[1].children[0].innerHTML; | |
textNode = textNode.substring(textNode.indexOf('-->')); | |
var title = textNode.substring(textNode.indexOf('-->') + 3, textNode.indexOf('<!--')); | |
listOfGames.push(title); | |
} | |
toClipboard(listOfGames.join('\n')); | |
} | |
/*********************************************************** | |
* Humble Bundle | |
**********************************************************/ | |
function insertHumbleBundleGraphicElements() | |
{ | |
var element = $('.hr-taglines-wrapper')[0]; | |
var anchor = document.createElement('a'); | |
anchor.innerHTML = '( Copy List Of Games )'; | |
anchor.href = '#'; | |
anchor.className = 'hr-tagline s-additional-content'; | |
anchor.style.display = 'block'; | |
anchor.onclick = startHumbleBundle; | |
insertAfter(anchor, element); | |
} | |
function startHumbleBundle() | |
{ | |
var titles = $('.dd-image-box-caption'); | |
var listOfGames = []; | |
for(var x = 0; x < titles.length; x++) { | |
listOfGames.push(titles[x].innerHTML.replace('<i class="hb hb-lock dd-caption-lock"></i>', '').replace('<br>','').replace('<br>','').trim()); | |
} | |
toClipboard(listOfGames.join('\n')); | |
} | |
/*********************************************************** | |
* Indie Gala | |
**********************************************************/ | |
function insertIndieGalaGraphicElements() | |
{ | |
if (!isIndieGalaBundlePage()){ | |
return; | |
} | |
var element = jQuery('p.bundle-claim-phrase')[0]; | |
var anchor = document.createElement('a'); | |
anchor.innerHTML = '<span>( Copy List Of Games )</span>'; | |
anchor.href = '#'; | |
anchor.className = 'rt-uppercase nomarginall'; | |
anchor.onclick = startIndieGala; | |
var paragraph = document.createElement('p'); | |
paragraph.className = 'bundle-claim-phrase'; | |
paragraph.append(anchor); | |
element.parentNode.insertBefore(paragraph, element); | |
} | |
function isIndieGalaBundlePage() | |
{ | |
if (jQuery('#buttonPurchase').size()) { | |
return true; | |
} | |
return false; | |
} | |
function startIndieGala() | |
{ | |
var titles = jQuery('.bundle-item-trading-cards-cont'); | |
var listOfGames = []; | |
for(var x = 0; x < titles.length; x++) { | |
listOfGames.push(titles[x].innerHTML.trim()); | |
} | |
toClipboard(listOfGames.join('\n')); | |
} | |
/*********************************************************** | |
* Go Go Bundle | |
**********************************************************/ | |
function insertGoGoBundleGraphicElements() | |
{ | |
var element = jQuery('#hikashop_product_left_part > h6')[0]; | |
var anchor = document.createElement('a'); | |
anchor.innerHTML = '( Copy List Of Games )'; | |
anchor.href = '#'; | |
anchor.className = 'rt-uppercase nomarginall'; | |
anchor.onclick = startGoGoBundle; | |
insertAfter(anchor, element); | |
} | |
function startGoGoBundle() | |
{ | |
var titles = jQuery("#hikashop_product_left_part > div > div > div > h5 > span"); | |
var listOfGames = []; | |
for(var x = 0; x < titles.length; x++) { | |
listOfGames.push(titles[x].innerHTML); | |
} | |
toClipboard(listOfGames.join('\n')); | |
} | |
/*********************************************************** | |
* Utility Functions | |
**********************************************************/ | |
function toClipboard(text) | |
{ | |
GM_setClipboard(text); | |
} | |
function getCurrentUrl() { | |
return window.location.href; | |
} | |
function insertAfter(newNode, referenceNode) { | |
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); | |
} | |
function insertBefore(newNode, referenceNode){ | |
referenceNode.parentNode.insertBefore(newNode, referenceNode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment