Last active
April 23, 2025 10:00
-
-
Save cosmo0/1154d158f9dc1f3b7f5fe841079b0cf0 to your computer and use it in GitHub Desktop.
Better Dekudeals - Tampermonkey / Greasemonkey / Violentmonkey
This file contains hidden or 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 Better Dekudeals | |
// @namespace http://dekudeals.com/ | |
// @version 1.2 | |
// @description Various improvements to Dekudeals | |
// @author cosmo0 | |
// @match https://www.dekudeals.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=dekudeals.com | |
// @require https://code.jquery.com/jquery-3.6.0.min.js | |
// @downloadURL https://gist.githubusercontent.com/cosmo0/1154d158f9dc1f3b7f5fe841079b0cf0/raw/dekudeals.user.js | |
// @updateURL https://gist.githubusercontent.com/cosmo0/1154d158f9dc1f3b7f5fe841079b0cf0/raw/dekudeals.user.js | |
// @grant GM.registerMenuCommand | |
// @grant GM_registerMenuCommand | |
// @grant GM_setClipboard | |
// @grant GM.setClipboard | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const $ = jQuery; | |
const items = $('.search-main > .browse-cards > .row > .col'); | |
// Create GM menus | |
const gmClip = GM.setClipboard || GM_setClipboard; | |
console.log('initializing Better DekuDeals'); | |
// styling | |
$('head').append(`<style type="text/css"> | |
.better-dekudeal .btn { color: #343a40; } | |
body[data-theme='dark'] .better-dekudeal .btn { color: #dddddd; } | |
.better-dekudeal .btn:hover { background: none; color: #6c757d; } | |
body[data-theme='dark'] .better-dekudeal .btn:hover { color: #999999; } | |
</style>`); | |
// move "hide" button outside the dropdown | |
console.log(items.length + ' items to process'); | |
items.each((idx, item) => { | |
const hideform = $(item).find('form[action$="/hide"]'); | |
hideform.removeClass('btn-group'); | |
const addToBtn = $(item).find('.watch-area'); | |
hideform.insertAfter(addToBtn); | |
}); | |
// create side menu container | |
const card = $('<div class="search-facet card hide-tail search-left-item better-dekudeal"><h6 class="card-header">Better DekuDeals</h6><div class="card-body p-2"></div></div>'); | |
card.insertBefore($('#search-left-content .search-facet').first()); | |
const container = card.find('.card-body'); | |
const btn = $('<button type="button" class="btn btn-outline-secondary mb-2 w-100 text-left p-0 border-0" style="white-space: normal;"></button>'); | |
// "hide all" button | |
const hideAll = btn.clone().text('Hide all on current page'); | |
hideAll.on('click', () => { | |
$('.search-main form[action$="/hide"] .watch-button').each((idx, item) => { | |
$(item).click(); | |
}); | |
}); | |
container.append(hideAll); | |
// copy only names | |
const gamesNamesButton = btn.clone().text('Copy only names'); | |
gamesNamesButton.on('click', () => { | |
get_games(false, false); | |
}); | |
container.append(gamesNamesButton); | |
// copy names and prices | |
const gamesButton = btn.clone().text('Copy names and price'); | |
gamesButton.on('click', () => { | |
get_games(true, false); | |
}); | |
container.append(gamesButton); | |
// copy only discounted | |
const discountButton = btn.clone().text('Copy only discounted'); | |
discountButton.on('click', () => { | |
get_games(true, true); | |
}); | |
container.append(discountButton); | |
/* | |
* Lists all games | |
*/ | |
function get_games(withPrice, onlyDiscounted) { | |
let text = ''; | |
items.each((_, c) => { | |
c = $(c); | |
const title = c.find('.main-link h6').text().trim(), | |
price = c.find('.d-flex.align-items-center.text-tight strong').text(), | |
discount = c.find('.badge-danger').text(), | |
lowest = c.find('.badge-warning').text(), | |
unavailable = c.find('.text-muted').text(); | |
if (onlyDiscounted && discount) { | |
text += title + ' : ' + price + ' (' + discount + (lowest ? (' - ' + lowest) : '') + ')\n'; | |
} | |
else if (!onlyDiscounted) { | |
text += title | |
if (withPrice) { | |
text += ' : ' + (price || unavailable); | |
if (discount) { | |
text += ' (' + discount + (lowest ? (' - ' + lowest) : '') + ')'; | |
} | |
} | |
text += '\n'; | |
} | |
}); | |
console.log(text); | |
gmClip(text); | |
alert('Games list copied to clipboard'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated - thanks!