Since my spirit animal is the sloth I'm obviously lazy as hell and would like some help figuring out a decently easy way to add a "search on ITAD" functionality to the right click menu in chrome. Like the way I'm able to mark text and do a google search.

As I realize that my imagination is quite limited regarding this and I'm sure there are other methods to accomplish a more convenient ITAD search any suggestion is welcome :)

7 years ago

Comment has been collapsed.

Deleted

This comment was deleted 2 years ago.

7 years ago
Permalink

Comment has been collapsed.

Thank you, I guess I should have done a search on chrome extensions myself but nothing turned up on google searches and I figured those would have worked :)

7 years ago
Permalink

Comment has been collapsed.

Sweet, thank you. Now I can go back to being a sloth :)

Edit: Grrr.. now I have another problem. It's just about impossible to mark the game title in the giveaway list :'(

7 years ago*
Permalink

Comment has been collapsed.

Put the mouse pointer a bit above the text. It should mark the text without clicking the hyperlink

7 years ago
Permalink

Comment has been collapsed.

oh wow, now I almost feel stupid. That's a great trick. Thanks again

7 years ago
Permalink

Comment has been collapsed.

Thanks to you, I just installed context search myself ^^

7 years ago
Permalink

Comment has been collapsed.

At first you could switch between default search engines in Firefox using a drop-down menu, and that let you search text in wikipedia, wordreference, twitter... by just right-clicking. They changed it dunno why, and it has been one of my most hated changes Firefox has done.

7 years ago
Permalink

Comment has been collapsed.

oh, that would indeed have been nice to do. One problem with the above extensions are that the context menus are cascaded which requires more clicks and mouse movements :S

I wonder how hard it wold be to hack in a search "icon" in one of the steamgifts overhaul scrips. It will probably take me days and hours to accomplish and save me almost a second for each search :D

7 years ago
Permalink

Comment has been collapsed.

If you mean adding an icon next to each game that leads you to its ITAD page... Isn't that already made somewhere? It looks trivial to do (adding a div to each giveaway name with the icon and the link)

7 years ago
Permalink

Comment has been collapsed.

It might be trivial and possible also already existing. I've just never really looked in to scripts or scripting with tampermonkey/greasemonkey etc. This would probably be the most convenient option for me though. I have to research a bit this coming weekend :)

7 years ago
Permalink

Comment has been collapsed.

Something like this?

// ==UserScript==
// @name        Steamgifts - ITAD links
// @description Adds an icon next to each giveaway that links to its ITAD page
// @include     https://www.steamgifts.com/
// @include     https://www.steamgifts.com/giveaways/*
// @version     0.1
// @grant       none
// ==/UserScript==

$('.giveaway__heading').each(function(){
    var gameName = $(this).children('a').text();
    var itadDiv = '<a class="giveaway__icon" rel="nofollow" target="_blank" href="https://isthereanydeal.com/#/search:'+gameName+'"><i class="fa fa-fw fa-gamepad"></i></a>';
    $(this).append(itadDiv);
});
7 years ago
Permalink

Comment has been collapsed.

That easy huh? That would be amazing. I'll give it a test run tonight. I'd honor your contribution with a spot in my whitelist, unfortunately you're already there :)

Edit: I couldn't wait. For some reason the string " BTAWLMEOX" gets added to every search. Probably a conflict with another script. That has to wait for tonight though. :)

7 years ago*
Permalink

Comment has been collapsed.

Yes, it is indeed a conflict with another script(s). Those strings are BTA, WL, ... But it is also because I wasn't careful with the code and selected all the children('a') >_<
I have looked around and saw this script by mahermen that adds info from ITAD inside each giveaway page, so I borrowed a pair of functions from him to save you a click when searching the game (you go directly to the ITAD game page, not the ITAD search page). Also this version shouldn't conflict with the rest of your mods scripts (now I only select children('a:first-child')).

// ==UserScript==
// @name        Steamgifts - ITAD links
// @description Adds an icon next to each giveaway that links to its ITAD page
// @include     https://www.steamgifts.com/
// @include     https://www.steamgifts.com/giveaways/*
// @version     0.2
// @grant       none
// ==/UserScript==

//Functions by mahermen
var staticReplacements = {
  "storiesofbethemfullmoon":"storiesofbethemfullmoonedition",
  "feariireborndlc":"feariireborn",
  "justcauseiiixl":"justcauseiiixledition"
};

function romanize(num) {
    var key = ["","i","ii","iii","iv","v","vi","vii","viii","ix"];
    return key[parseInt(num)];
}

function encodeName(str){
    str = str.toLowerCase(); //lowercase
    str = str.replace(/[1-9]/g, romanize);//romanize digits
    str = str.replace(/(^the[^a-z])|([^a-z]the[^a-z])|([^a-z]the$)/g, ""); //remove "the", but not e.g. "other" or "them"
    str = str.replace(/\+/g, "plus");    //spell out "plus"
    str = str.replace(/\&/g, "and");    //spell out "and"
    str = str.replace(/[^a-z0]/g, '');    //remove remaining invalid characters, like spaces, braces, hyphens etc
    return staticReplacements[str] || str;
}

//Main
$('.giveaway__heading').each(function(){
    var gameName = $(this).children('a:first-child').attr('href').split('/')[3];
    var itadDiv = '<a class="giveaway__icon" rel="nofollow" target="_blank" href="https://isthereanydeal.com/#/page:game/info?plain='+encodeName(gameName)+'"><i class="fa fa-fw fa-eur"></i></a>';
    $(this).append(itadDiv);
});

Rarely this can fail due to special URIs given to the games, in that case you can add an exception in staticReplacements var, and report it to mahermen in his thread.

View attached image.
7 years ago*
Permalink

Comment has been collapsed.

Bug: steamgifts urls doesn't include characters like "+" or "&" but ITAD replaces them instead of removing them so all the games with those characters will lead to an ITAD error page :( I am getting the name from the url because when the game name is too long it is truncated.

I could get the game name from the giveaway page, but that would mean making more than 50 requests per page and obviously I don't like that. If you prefer you can use the first version with some modifications, it would mean one more click for you but you should be able to (almost) always find the game.

// ==UserScript==
// @name        Steamgifts - ITAD links
// @description Adds an icon next to each giveaway that links to its ITAD page
// @include     https://www.steamgifts.com/
// @include     https://www.steamgifts.com/giveaways/*
// @version     0.1.b
// @grant       none
// ==/UserScript==

//EDIT: SAME BUG THAN VERSION 0.2 ARGGHHGHG T__T

function encodeName(str){
  str = str.replace(/\-/g, " ");
  return str;
}

$('.giveaway__heading').each(function(){
    var gameName = $(this).children('a:first-child').attr('href').split('/')[3];
    var itadDiv = '<a class="giveaway__icon" rel="nofollow" target="_blank" href="https://isthereanydeal.com/#/search:'+encodeName(gameName)+'"><i class="fa fa-fw fa-eur"></i></a>';
    $(this).append(itadDiv);
});

Nope, that fails too T_T I wish I could search ITAD game pages by their appID
Don't you like when trivial things end up being not so trivial?

7 years ago*
Permalink

Comment has been collapsed.

You could take the game name from the title and fall back to fetching the full name from the GA page only when its truncated (.endsWith("...")).
This way you only need to make a few additional requests every page.
Check SgApi Giveaway Tools for that, especially the loadGiveaway() function.

Giveaways.loadGiveaway(href, function(ga){console.log(ga.gameTitle);})
7 years ago
Permalink

Comment has been collapsed.

Thanks for your advice, mahermen. I just wanted to make a small script to help Spiff00. As it is impossible to do what I wanted to do without using more than 1 request (or using ITAD's API) I'm out. Anyway it seems he is already using your script so his needs are well covered at this point :)

7 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

Thanks Sighery. Yes I saw it, but having to ask for an API key + additional requests/load times for just a small and trivial script as I wanted to make made me close the tab.

7 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

Thanks again Sighery, but as I told mahermen I'm out. I wanted to do it in a single request but it is impossible :(
At least there are not many games with & or + in the name...

7 years ago*
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

But I would still have to send requests to your server, right? To get the "plain" name. That is what I mean, extra requests. Even just requesting the plain name of those games which name is truncated, as mahermen suggested, it would mean an average of 5 requests to your server per page.

In the version 0.2 posted some posts above I already bypassed the search page, borrowing mahermen function to encode the name of the game into the "plain" name accepted by ITAD. But it fails if the game contains "&" or "+" signs.

It would be the same making a request to your server to get the plain name, or making a request to the giveaway page to get the complete name from the title and then apply the encodeName function to it. Indeed this last option would be better since I can assure the server will never be down (the request is made by loading the giveaway page of that same server).

Anyway, I just create small scripts for personal use as pastime, kinda like small puzzles. There are already better programmers in this forum whose scripts are fully compatible between them, make more things, are better made, and updated frequently. Under my point of view if the initial task can't be made without making extra requests, it is just not worth and it is better using just another better script as mahermen's one.

BTW is there some script out there that asks you before leaving the page if you are writing a comment? Not like this is the second time I'm writing this because I pressed that stupid button I never use in my mouse that leads me to the previous page....

7 years ago
Permalink

Comment has been collapsed.

This has been very helpful to me and so far I've not encountered any bugs. However reading about the other ITAD script and trying it out for a bit made me want to fetch some of that data and put it beside the search icons right away. This is surely going to end up with me researching scripting in this environment and probably failing badly at it :D

7 years ago
Permalink

Comment has been collapsed.

Sign in through Steam to add a comment.