text: function checkIfArrayHasObjectWithProp(e,t,n){var o=!1,i=null;return e.length&&e.forEach(function(e,s){e[t]==n&&(o=!0,i=s)}),{isInArray:o,position:i}}var storage={target:chrome.storage.local,set:function(e,t){this.target.set(e,t)},get:function(e,t){this.target.get(e,t)}},options={changeGeneralRelevance:function(){var e=$(this).val();storage.set({generalRelevance:e})},getGeneralRelevance:function(e){storage.get("generalRelevance",e)},setDefaultGeneralRelevance:function(){var e=this;options.getGeneralRelevance(function(t){e.val(t.generalRelevance||0)})},appendDynamicHtml:function(e,t,n){var o=$(t).html(),i=Mustache.to_html(o,e);$(n).html(i)},getWhitelistedDomains:function(e){storage.get("whitelistedDomains",e)},removeDomainFromWhitelist:function(e,t){options.getWhitelistedDomains(function(n){n.whitelistedDomains&&n.whitelistedDomains.indexOf(e)!==-1&&(n.whitelistedDomains.splice(n.whitelistedDomains.indexOf(e),1),storage.set({whitelistedDomains:n.whitelistedDomains},t))})},removeCustomRelevanceDomain:function(e,t){options.getCustomRelevanceDomains(function(n){n.customRelevanceDomains&&checkIfArrayHasObjectWithProp(n.customRelevanceDomains,"domain",e.domain).isInArray&&(n.customRelevanceDomains.splice(checkIfArrayHasObjectWithProp(n.customRelevanceDomains,"domain",e.domain).position,1),storage.set({customRelevanceDomains:n.customRelevanceDomains},t))})},addCustomRelevanceDomain:function(e,t){options.getCustomRelevanceDomains(function(n){n.customRelevanceDomains?checkIfArrayHasObjectWithProp(n.customRelevanceDomains,"domain",e.domain).isInArray?options.resetAddCustomRelevanceDomains():(n.customRelevanceDomains.push(e),storage.set({customRelevanceDomains:n.customRelevanceDomains},t)):storage.set({customRelevanceDomains:[e]},t)})},getCustomRelevanceDomains:function(e){storage.get("customRelevanceDomains",e)},resetAddCustomRelevanceDomains:function(){$(".custom-domain-input-js").val(""),$("#custom-relevance-select").val(0),$(".custom-domain-row-container-js").addClass("hide")}};$(function(){var e=$("#general-relevance");options.setDefaultGeneralRelevance.call(e),e.on("keyup",function(){options.changeGeneralRelevance.call(this)}),options.getWhitelistedDomains(function(e){if(e.whitelistedDomains&&e.whitelistedDomains.length){var t={whitelist:e.whitelistedDomains};$(".no-whitelist-js").addClass("hide"),$(".whitelist-items-no-js").text(e.whitelistedDomains.length),options.appendDynamicHtml(t,"#whitelist",".whitelist-container-js")}}),options.getCustomRelevanceDomains(function(e){if(e.customRelevanceDomains&&e.customRelevanceDomains.length){var t={customDomain:e.customRelevanceDomains};options.appendDynamicHtml(t,"#custom-domain-list",".custom-domains-list-js")}}),$("body").on("click",".remove-item-from-whitelist-js",function(){var e=this,t=$(".whitelist-items-no-js"),n=+t.text(),o=$(e).attr("data-url");options.removeDomainFromWhitelist(o,function(){$(e).parent().remove(),n--,0===n&&$(".no-whitelist-js").removeClass("hide"),t.text(n)})}),$(".add-custom-domain-js").on("click",function(){$(".custom-domain-row-container-js").removeClass("hide")}),$("body").on("keyup",".custom-domain-input-js",function(){var e=$(".custom-domain-save-js");$(this).val().trim()?e.removeAttr("disabled"):e.prop("disabled",!0)}),$("body").on("click",".custom-domain-save-js",function(){options.addCustomRelevanceDomain({domain:$(".custom-domain-input-js").val(),relevance:$("#custom-relevance-select").val()},function(){options.resetAddCustomRelevanceDomains(),options.getCustomRelevanceDomains(function(e){if(e.customRelevanceDomains&&e.customRelevanceDomains.length){var t={customDomain:e.customRelevanceDomains};options.appendDynamicHtml(t,"#custom-domain-list",".custom-domains-list-js")}})})}),$("body").on("click",".remove-item-from-custom-domains-list-js",function(){var e=this,t=$(e).attr("data-url");options.removeCustomRelevanceDomain({domain:t},function(){$(e).parent().remove()})})});