Show coupons available on game page
目前為
// ==UserScript==
// @name IsThereCouponForThis
// @namespace https://greasyfork.org/users/2205
// @description Show coupons available on game page
// @include http://store.steampowered.com/app/*
// @include https://store.steampowered.com/app/*
// @version 1.1
// @run-at document-end
// @grant GM.xmlhttpRequest
// @grant GM_xmlhttpRequest
// @language English
// ==/UserScript==
+function(){
window.addEventListener('load', function() {
GM_xmlhttpRequest({
method: "GET",
url: "https://pastebin.com/raw/i8ri7Ne7",
onload: function(response) {
var subid = document.getElementsByName('subid')[0].value;
var couponlist = response.responseText;
couponlistlines = couponlist.split('\n');
var available="Coupons: ";
var availcount=0;
for (var i=0 ; i<couponlistlines.length ; i++) {
coupondata=couponlistlines[i].split('\t');
if (coupondata.length>3) {
subids=coupondata[3].split(',');
}
for (var j=0; j<subids.length; j++) {
if (subids[j]===subid) {
if (availcount>0) {
available=available+", ";
}
available=available+coupondata[0];
availcount++;
}
}
}
container=document.getElementsByClassName('game_area_purchase_platform')[0];
if (availcount>0) {
container.innerHTML="<span title=\""+available+"\" class=\"platform_img\" style=\"background-color:#3c3d3e;font-size:18px;text-align: center;cursor:default\">$</span>"+container.innerHTML;
} else {
container.innerHTML="<span title=\"No Coupons Found\" class=\"platform_img\" style=\"background-color:#3c3d3e;font-size:18px;text-align: center;cursor:default\">X</span>"+container.innerHTML;
}
},
onerror: function() {
console.log('Error.');
}
});
});
}();