diff --git a/enhancedsteam.js b/enhancedsteam.js index 08d2b5d4..bc1dc506 100644 --- a/enhancedsteam.js +++ b/enhancedsteam.js @@ -981,6 +981,69 @@ function validate_price (priceText, event) { var price = Number(priceText); return !(Number.isNaN(price)); } + +var uncensorpatch_module = (function () { + var uncensor_json = null; + + var pub = {}; + + pub.apply_uncensor_node = function (node) { + storage.get(function (settings) { + if (settings.show_uncensorpatch_info) { + if(uncensor_json === null) pub.get_json(); + else { + var appid = parseInt($(node).attr("data-ds-appid")); + if ($("#es_uncensor_exists").is(".checked")) { + if ($.inArray(appid, uncensor_json["exists"]) === -1) $(node).hide(); + } + if ($("#es_uncensor_unsure").is(".checked")) { + if (($.inArray(appid, uncensor_json["exists"]) > -1) + | ($.inArray(appid, uncensor_json["not_exists"]) > -1)) { + $(node).hide(); + } + } + if ($("#es_uncensor_not_exists").is(".checked")) { + if ($.inArray(appid, uncensor_json["not_exists"]) === -1) $(node).hide(); + } + if ($(document).height() <= $(window).height()) { + load_search_results() + } + } + } + }); + } + + pub.apply_uncensor = function () { + storage.get(function (settings) { + if (settings.show_uncensorpatch_info) { + if(uncensor_json === null) pub.get_json(); + else { + $(".search_result_row").each(function() { + $(this).css("display", "block"); + pub.apply_uncensor_node(this); + }); + } + } + }); + } + + pub.get_json = function () { + storage.get(function (settings) { + if (settings.show_uncensorpatch_info) { + if(uncensor_json === null) { + $.getJSON('https://www.uncensorpat.ch/api/get-data', function(ret_json) { + uncensor_json = ret_json; + pub.apply_uncensor(); + }); + } else { + pub.apply_uncensor(); + } + } + }); + } + + return pub; +}()); function hexToRgb(hex) { var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); @@ -3406,6 +3469,87 @@ function add_hide_buttons_to_search() { } }); } + +function add_uncensor_buttons_to_search() { + storage.get(function(settings) { + if (settings.show_uncensorpatch_info) { + if (settings.uncensor_exists === undefined) { settings.uncensor_exists = false; storage.set({'uncensor_exists': settings.uncensor_exists}); } + if (settings.uncensor_unsure === undefined) { settings.uncensor_unsure = false; storage.set({'uncensor_unsure': settings.uncensor_unsure}); } + if (settings.uncensor_not_exists === undefined) { settings.uncensor_not_exists = false; storage.set({'uncensor_not_exists': settings.uncensor_not_exists}); } + + $("#advsearchform").find(".rightcol").prepend(` +
+ `); + + if (settings.uncensor_exists) { + $("#es_uncensor_exists").addClass("checked"); + } + if (settings.uncensor_unsure) { + $("#es_uncensor_unsure").addClass("checked"); + } + if (settings.uncensor_not_exists) { + $("#es_uncensor_not_exists").addClass("checked"); + } + + function add_uncensor_buttons_to_search_click() { + uncensorpatch_module.get_json(); + } + + if (settings.uncensor_exists | settings.uncensor_unsure | settings.uncensor_not_exists) { + add_uncensor_buttons_to_search_click(); + } + + $("#es_uncensor_exists").click(function() { + if ($("#es_uncensor_exists").hasClass("checked")) { + $("#es_uncensor_exists").removeClass("checked"); + storage.set({'uncensor_exists': false }); + } else { + $("#es_uncensor_exists").addClass("checked"); + storage.set({'uncensor_exists': true }); + } + add_uncensor_buttons_to_search_click(); + }); + + $("#es_uncensor_unsure").click(function() { + if ($("#es_uncensor_unsure").hasClass("checked")) { + $("#es_uncensor_unsure").removeClass("checked"); + storage.set({'uncensor_unsure': false }); + } else { + $("#es_uncensor_unsure").addClass("checked"); + storage.set({'uncensor_unsure': true }); + } + add_uncensor_buttons_to_search_click(); + }); + + $("#es_uncensor_not_exists").click(function() { + if ($("#es_uncensor_not_exists").hasClass("checked")) { + $("#es_uncensor_not_exists").removeClass("checked"); + storage.set({'uncensor_not_exists': false }); + } else { + $("#es_uncensor_not_exists").addClass("checked"); + storage.set({'uncensor_not_exists': true }); + } + add_uncensor_buttons_to_search_click(); + }); + } + }); +} function set_homepage_tab() { storage.get(function(settings) { @@ -3939,6 +4083,31 @@ function add_hltb_info(appid) { }); } } + +function add_uncensor_patch_info(appid) { + storage.get(function(settings) { + if (settings.show_uncensorpatch_info) { + $.getJSON('https://www.uncensorpat.ch/api/game/'+appid, function(game_uncensor_json) { + uncensor_patch_html = "