Skip to content

Instantly share code, notes, and snippets.

@korden32
Last active September 19, 2018 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korden32/06d771a0e23a41140c86 to your computer and use it in GitHub Desktop.
Save korden32/06d771a0e23a41140c86 to your computer and use it in GitHub Desktop.
Adds incompatible/report buttons in game hubs & user profile galleries
// ==UserScript==
// @name UGC FastModerate
// @author KorDen
// @version 1.0.1
// @description Adds incompatible/report buttons in game hubs & user profile galleries
// @grant none
// @include *//steamcommunity.com/app/*/images*
// @include *//steamcommunity.com/app/*/screenshots*
// @include *//steamcommunity.com/
// @include *//steamcommunity.com/?*
// @include *//steamcommunity.com/id/*/images*
// @include *//steamcommunity.com/id/*/screenshots*
// @include *//steamcommunity.com/profiles/*/images*
// @include *//steamcommunity.com/profiles/*/screenshots*
// ==/UserScript==
contentEval( function get_http(url, callback) {
var http = new window.XMLHttpRequest();
http.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200)
callback(this.responseText);
};
http.open('GET', url, true);
http.send(null);
} );
var offset = 0;
(function() {
if($J('div.apphub_Card').length > 0) {
// Hubs
window.onscroll = function() {
if(window.pageYOffset < offset)
return;
offset = window.pageYOffset;
$J('div.apphub_Card[data-modal-content-url]').each(function () {
var card = $J(this);
//Remove insideModal
var content = card.find('div.apphub_CardContentClickable');
if(content.length > 0) {
content.wrap("<a href='" + card.attr('data-modal-content-url') + "' target=_blank></a>");
card.removeAttr('data-modal-content-url');
}
//Add buttons
var bBan = card.find('a.btn_grey_grey[onclick^="PublishedFileBan"]');
var rating = card.find('div.apphub_CardRating');
if(bBan.length > 0 && rating.length > 0) {
rating.css('min-width','0px');
if(rating.attr('class').match(/rateUpHide/))
rating.css('padding','5px');
var id = bBan.attr('onclick').match(/PublishedFileBan\((.+), (.+)\);/);
var appid = id[2];
id = id[1];
if(hasAdminPrivileges) {
bBan.hide();
rating.after(' &nbsp;<a onclick="UGCBan(' + id + ', ' + appid + ', 1);" class="btn_grey_grey btn_small_thin" id="ban_btn_' + id + '"><span style="color:#ff0000;">Ban</span></a> <a onclick="UGCIncompatible(' + id + ', ' + appid + ', 1);" class="btn_grey_grey btn_small_thin" id="hide_btn_' + id + '"><span style="color:#eeee00;">Hide</span></a> ');
} else {
rating.after(' &nbsp;<a onclick="UGCReport(' + id + ');" class="btn_grey_grey btn_small_thin" id="report_btn_' + id + '"><span style="color:#ff8800;">Report</span></a> ');
}
get_http('//steamcommunity.com/sharedfiles/filedetails/?id=' + id, function(txt) {
if(hasAdminPrivileges) {
var html = "";
var steamid = txt.match(/"owner":"(.+)","total/)[1];
if(steamid > 0)
html += ' <a href="//steamcommunity.com/app/' + appid + '/appreportedcontent/?steamid=' + steamid + '" class="btn_grey_grey btn_small_thin"><span>View All</span></a> ';
var weight = txt.match(/<td>(.+)<\/td>\r\n <td>Times Reported/);
if(weight) {
if(weight[1] > 0)
html += '<span style="color:#ff0000;" >';
else
html += '<span>';
html += '(' + weight[1] + ') </span>';
}
$J('#hide_btn_' + id).after(html);
} else if (txt.match(/general_btn report tooltip toggled/)) {
$J( '#report_btn_' + id ).replaceWith('<a class="btn_green_white_innerfade btn_small_thin btn_disabled"><span>Reported</span></a>');
}
});
}
});
}
} else if($J('.image_grid_dates').length > 0) {
// Profiles
$J('.imageWall4Floaters').attr('style', 'margin-left: 185px; margin-top: -222px;'); //-207px
$J('.profile_media_item').each(function () {
var item = $J(this);
var id = item.attr('href').match(/\?id=(.+)/)[1];
var banned = item.html().match(/imgWallItem banned/);
var html = '<div style="position:relative; left:10px; top:3px;">';
if(banned) {
html += '<a class="btn_darkblue_white_innerfade btn_small_thin btn_disabled"><span>BANNED</span></a><br><span>&nbsp;</span>';
} else {
html += '<a class="btn_darkblue_white_innerfade btn_small_thin" id="report_btn_' + id + '" onclick="UGCReport(' + id + ')"><span style="color: #ffaa44;">Report</span></a>';
html += ' <a id="ban_btn_' + id + '" class="btn_darkblue_white_innerfade btn_small_thin" style="display:none;"><span>Ban</span></a>';
html += ' <a id="hide_btn_' + id + '" class="btn_darkblue_white_innerfade btn_small_thin" style="display:none;"><span>Hide</span></a>';
html += ' <span id="game_' + id + '"><br>Loading...</span>';
get_http('//steamcommunity.com/sharedfiles/filedetails/?id=' + id, function(txt) {
var state = "";
if(txt.match(/visibilityNotificationFriendsOnly" >/))
state = "<span style='color:#ffff00'>FriendsOnly</span>";
if(!txt.match(/UpdateBanFileStatus()/)) {
if (txt.match(/report tooltip toggled/))
$J( '#report_btn_' + id ).replaceWith('<a class="btn_darkblue_white_innerfade btn_small_thin btn_disabled"><span>Reported</span></a>');
} else {
$J( '#report_btn_' + id ).hide();
var appid = txt.match(/name="appid" value="(.+)"/);
if (appid) {
$J( '#ban_btn_' + id ).attr('onclick','UGCBan(' + id + ','+ appid[1] + ', 1);');
$J( '#ban_btn_' + id ).show();
if( txt.match(/incompatibleNotification" >/) ) {
$J( '#imgWallItem_' + id ).attr('class','imgWallItem incompatible')
} else {
$J( '#hide_btn_' + id ).attr('onclick','UGCIncompatible(' + id + ','+ appid[1] + ', 1);');
$J( '#hide_btn_' + id ).show();
}
}
if(!state && txt.match(/visibilityNotificationPrivate" >/))
state = "<span style='color:#ff8800'>Private</span>";
}
state += '<br>';
var game=txt.match(/apphub_AppName ellipsis">(.+)<\//);
state += game ? game[1] : "Steam Artwork";
$J( '#game_' + id ).html(state);
});
}
html += '</div>';
item.after(html);
});
}
})();
contentEval( function UGCReport(id) {
var reason = prompt("Report reason:","");
if(reason) {
var options = {
method: 'post',
postBody: 'id=' + id + '&description=' + reason + '&sessionid=' + g_sessionID,
onComplete: (function(id){
return function(transport) {
$J( '#report_btn_' + id ).replaceWith('<a class="btn_grey_grey btn_small_thin"><span style="color:#33ff33;">Reported</span></a>');
}
}(id))
};
new Ajax.Request('//steamcommunity.com/sharedfiles/reportitem', options);
}
} );
contentEval( function UGCIncompatible(id , appid, state) {
var bHide = $J( '#hide_btn_' + id );
bHide.html('<span>H...</span>');
var options = {
method: 'post',
postBody: 'id=' + id + '&appid=' + appid + '&sessionid=' + g_sessionID + '&incompatible=' + state,
onComplete: (function(id) {
return function(transport) {
if(state == 1) {
bHide.html('<span style="color: #99ff33;">UnHide</span></a>');
bHide.attr('onclick', bHide.attr('onclick').replace(", 1);", ", 0);"));
} else {
bHide.html('<span style="color: #ffff33;">Hide</span></a>');
bHide.attr('onclick', bHide.attr('onclick').replace(", 0);", ", 1);"));
}
}
}(id))
};
new Ajax.Request('//steamcommunity.com/sharedfiles/updateincompatible', options);
} );
contentEval( function UGCBan( id, appid, state) {
var bBan = $J( '#ban_btn_' + id );
bBan.html('<span>B...</span>');
var options = {
method: 'post',
postBody: 'id=' + id + '&appid=' + appid + '&sessionid=' + g_sessionID + '&IsBanned=' + state + '&reason=""',
onComplete: (function(id) {
return function(transport) {
if(state == 1) {
bBan.html('<span style="color: #8888ff;">UnBan</span></a>');
bBan.attr('onclick', bBan.attr('onclick').replace(", 1);", ", 0);"));
} else {
bBan.html('<span style="color: #ff0000;">Ban</span></a>');
bBan.attr('onclick', bBan.attr('onclick').replace(", 0);", ", 1);"));
}
}
}(id))
};
new Ajax.Request( '//steamcommunity.com/sharedfiles/ban', options);
} );
function contentEval(source) {
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = source;
document.body.appendChild(script);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment