Last active
October 3, 2015 19:58
-
-
Save adaliabooks/e9942593d89db2006e31 to your computer and use it in GitHub Desktop.
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 Downloader Links on Main Library Page | |
// @namespace https://gist.github.com/adaliabooks/ | |
// @version 0.2 | |
// @description Restores the GoG Downloader links to the main game page on the library | |
// @include https://www.gog.com/account* | |
// @include http://www.gog.com/account* | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js | |
// @require https://meetselva.github.io/attrchange/javascripts/attrchange.js | |
// @author adaliabooks | |
// @updateURL https://gist.github.com/adaliabooks/e9942593d89db2006e31/raw/ | |
// @downloadURL https://gist.github.com/adaliabooks/e9942593d89db2006e31/raw/ | |
// @grant none | |
// ==/UserScript== | |
$.fn.changeElementType = function(newType) { | |
var attrs = {}; | |
$.each(this[0].attributes, function(idx, attr) { | |
attrs[attr.nodeName] = attr.nodeValue; | |
}); | |
var newelement = $("<" + newType + "/>", attrs).append($(this).contents()); | |
this.replaceWith(newelement); | |
return newelement; | |
}; | |
var downloadRows = $(".game-details__column--left"); | |
$('.game-details__header').parent().attrchange({ | |
trackValues: true, | |
callback: function (event) { | |
if(event.attributeName == "class") | |
{ | |
if(!(event.newValue === "ng-hide")) | |
{ | |
var downloaderLinksURL = $("a:contains('GOG Downloader links')").attr('href'); | |
console.log(downloaderLinksURL); | |
$.get(downloaderLinksURL, function( data ) { | |
var $page = $(data); | |
var downloadLinks = $page.find('.downloader__links'); | |
downloadLinks.find('h2').remove(); | |
/*downloadLinks.find('h2').each(function (index) { | |
$(this).changeElementType('span').css('font-size', '14px'); | |
});*/ | |
downloadLinks.find('a').addClass('game-link row ng-scope row__column').css({'font-size': '12px', 'padding': '0!important', 'height': '30px'}); | |
downloadLinks.prepend('<h4>GoG Downloader Links</h4>'); | |
console.log(downloadLinks); | |
$('.downloader__links').remove(); | |
downloadRows.append(downloadLinks); | |
}); | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment