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(` +
+
` + localized_strings.uncensor.narrow_by + `
+
+
+
+ ` + localized_strings.uncensor.exists + ` +
+
+
+ ` + localized_strings.uncensor.unsure + ` +
+
+
+ ` + localized_strings.uncensor.not_exists + ` +
+
+
+ `); + + 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 = "
" + localized_strings.uncensor.title + "
" + + ""; + $("div.game_details:first").after(uncensor_patch_html); + }); + } + }); +} // Add link to game pages on pcgamingwiki.com function add_pcgamingwiki_link(appid) { @@ -6559,6 +6728,7 @@ function bind_ajax_content_highlighting() { endless_scrolling(); start_highlights_and_tags(); process_early_access(); + uncensorpatch_module.apply_uncensor(node); } if ($(node).children('div')[0] && $(node).children('div')[0].classList.contains("blotter_day")) { @@ -6581,6 +6751,7 @@ function bind_ajax_content_highlighting() { check_early_access(node); apply_rate_filter(node); apply_price_filter(node); + uncensorpatch_module.apply_uncensor_node(node); } if (node.classList && node.classList.contains("market_listing_row_link")) highlight_market_items(); @@ -8647,6 +8818,7 @@ $(document).ready(function(){ add_widescreen_certification(appid); add_hltb_info(appid); + add_uncensor_patch_info(appid); add_steam_client_link(appid); add_pcgamingwiki_link(appid); add_steamcardexchange_link(appid); @@ -8726,6 +8898,7 @@ $(document).ready(function(){ case /^\/search\/.*/.test(path): endless_scrolling(); add_hide_buttons_to_search(); + add_uncensor_buttons_to_search(); add_exclude_tags_to_search(); break; diff --git a/js/options.js b/js/options.js index 65e58b0a..c5bfb9e5 100644 --- a/js/options.js +++ b/js/options.js @@ -104,6 +104,7 @@ var settings_defaults = { "show_early_access": true, "show_alternative_linux_icon": false, "show_itad_button": false, + "show_uncensorpatch_info": false, "skip_got_steam": false, "hideinstallsteambutton": false, diff --git a/localization/en/strings.json b/localization/en/strings.json index 5e6f051b..02f3c9b1 100644 --- a/localization/en/strings.json +++ b/localization/en/strings.json @@ -288,6 +288,15 @@ "help": "Click here to help", "wrong": "Wrong game?" }, + "uncensor": { + "title": "Uncensor Patch Details", + "narrow_by": "Filter by uncensor patch", + "status": "Uncensor patch status:", + "visit": "View details on UncensorPat.ch", + "exists": "Available", + "unsure": "Unsure", + "not_exists": "Doesn't exist" + }, "library": { "in_library": "In Library", "error_loading_library": "Couldn't load your library.", @@ -421,6 +430,7 @@ "show_badge_progress": "Show apps badge progress on store pages", "show_wishlist_link": "Show a Wishlist link on profiles", "show_wishlist_count": "Show the number of items on Wishlist", + "show_uncensorpatch_info": "Show UncensorPat.ch info and filters (18+ only)", "lang": { "english": "English", "brazilian": "Portuguese-Brazil", diff --git a/options.html b/options.html index ed21e7bf..5a764939 100644 --- a/options.html +++ b/options.html @@ -230,6 +230,7 @@
  • +