Ahab / shoplifting

// ==UserScript==
// @name shoplifting
// @namespace torn.com
// @include *torn.com/*
// @author Ahab [1735214]
// @version 0.7
// @grant GM_addStyle
// @license MIT
// ==/UserScript==

GM_addStyle(`
.added_Container{
  z-index: 1;
  margin: 10px 10px 10px 10px;
  left: 28vw;
}
@media (max-width: 1750px) {
  .added_Container{
    left: 50%;
  }
}
@media (max-width: 576px) {
  .added_Container{
    left: calc(100vh - 1rem);
  }
}
.section_Header{
  background: repeating-linear-gradient(90deg,#2e2e2e,#2e2e2e 2px,#282828 0,#282828 4px);
  color: #fff;
  padding:5px 5px 5px 5px;
}
.shop_Status{
  display: grid;
  align-items: center;
  grid-template-columns: 120px repeat(auto-fit, minmax(calc((100% - 100px) / 3), 1fr)) 50px;
  padding: 1px 5px 1px 5px;
}
.shop_Status:not(:last-child){
  border-bottom: 1px solid black;
}
.sec_Icon{
  background-image: url('https://www.torn.com/images/v2/crimes/04-shoplifting/security-measures-light.svg');
  background-repeat: no-repeat;
  height: 36px;
  width: 36px;
  grid-area: 1 / 1 / 2 / 2;
}
.two_Camera{
  background-position-y: -36px;
}
.three_Camera{
  background-position-y: -72px;
}
.four_Camera{
  background-position-y: -108px;
}
.one_Guard{
  background-position-x: -36px;
}
.two_Guard{
  background-position-x: -36px;
  background-position-y: -36px;
}
.blank{
  background-image: url();
}
.checkpoint{
  background-position-x: -72px;
}
._active{
  grid-area: 1 / 1 / 2 / 2;
}
._disabled{
  height: 2px;
  grid-area: 1 / 1 / 2 / 2;
  top: calc(50% - 1px);
  transform: rotate(-45deg);
  transform-origin: center center;
  width: 100%;
  position: relative;
  background-color: rgb(85, 168, 47);
}
.icon_Container{
  display: grid;
  grid-area: 1 / 2 / 1 / 2;
  justify-self: end;
  scale: 0.8;
  border-radius: 50px;
}
.icon_Container2{
  display: grid;
  grid-area: 1 / 3 / 1 / 3;
  justify-self: end;
  scale: 0.8;
  border-radius: 50px;
}
.circle{
  grid-area: 1 / 1 / 2 / 2;
}
.shop_Name{
  grid-area: 1 / 1 / 1 / 1;
  width: fit-content;
}
.marked{
    box-shadow: 0px 0px 7px 2px #9899b0;
}
`)

if(localStorage.shopListVis==undefined){
    localStorage.shopListVis = 'grid'
}
if(localStorage.shopListAlerts==undefined){
    localStorage.shopListAlerts = JSON.stringify({"sallys_sweet_shop":{"cam":0,"both":0,"name":"Sally's Sweet Shop","camSeenAt":0,"guardSeenAt":0,"bothSeenAt":0},"Bits_n_bobs":{"cam":0,"both":0,"name":"Bits 'n' Bobs","camSeenAt":0,"guardSeenAt":0,"bothSeenAt":0},"tc_clothing":{"cam":0,"guard":0,"both":0,"name":"TC Clothing","camSeenAt":0,"guardSeenAt":0,"bothSeenAt":0},"super_store":{"cam":0,"guard":0,"both":0,"name":"Super Store","camSeenAt":0,"guardSeenAt":0,"bothSeenAt":0},"pharmacy":{"cam":0,"guard":0,"both":0,"name":"Pharmacy","camSeenAt":0,"guardSeenAt":0,"bothSeenAt":0},"cyber_force":{"cam":0,"guard":0,"both":0,"name":"Cyber Force","camSeenAt":0,"guardSeenAt":0,"bothSeenAt":0},"jewelry_store":{"cam":0,"guard":0,"both":0,"name":"Jewelry Store","camSeenAt":0,"guardSeenAt":0,"bothSeenAt":0},"big_als":{"cam":0,"guard":0,"both":0,"name":"Big Al's Gun Shop","camSeenAt":0,"guardSeenAt":0,"bothSeenAt":0}})
}

var keyCheck = setInterval(function(){
    if($('.added_Container')){
        clearInterval(keyCheck);
        if(localStorage.shopListAPI === undefined || localStorage.shopListAPI == 'null' || localStorage.shopListAPI.length == 0){
            $('.section_Header').append('<button id="shopcreateKey" style="color: #ddd; font-size: small; background-color: #444; cursor: pointer; border-radius: 10px; width: 120px; margin-left: 5px;">Create api key</button>')
            $('button[id*="shopcreateKey"]').on('click', function(event) {
                window.open('https://www.torn.com/preferences.php#tab=api?step=addNewKey&title=shopAPI&&torn=shoplifting')
            })
        }
    }
}, 200);

if($(window)[0].location.href.indexOf('api') > -1){
    var newkeyExists = setInterval(function(){
        if($('input[id*=key-popup]').length){
            clearInterval(newkeyExists);
            localStorage.shopListAPI = $('input[id*=key-popup]')[0].value
            alert('New key saved, can close this page')
            $('#shopcreateKey').remove()
        }
    }, 500);
}

$("<div class='added_Container cont-gray'><div class='section_Header'>Shop Security Status</div><div class='shop_List' style=display:"+localStorage.shopListVis+"></div>").prependTo($('div[class^="content-wrapper"]')[0])

function getShop(){
    var shopListAlerts = JSON.parse(localStorage.shopListAlerts)
    var shopsHTML = '';
    if(localStorage.shopListAPI != undefined || localStorage.shopListAPI != null || localStorage.shopListAPI.length != 0){
        if($(window)[0].location.href.indexOf('recaptcha') == -1){
            var getapiData = new Promise((resolve, reject) => {
                var apiData = getAction({
                    type: "GET",
                    action: `https://api.torn.com/torn/?selections=shoplifting&key=${localStorage.shopListAPI}`,
                })
                resolve(apiData)
            })
            Promise.all([getapiData]).then(([apiData]) => {
                if(apiData.hasOwnProperty("error")){
                    alert('Error code - '+apiData.error.code+"  | "+apiData.error.error)
                    setInterval(console.log('Key unblocked'), 120000);
                }else{
                    apiData = apiData
                    shopsHTML += "<div class='shop_Status'><div class='shop_Name' id='sallys_sweet_shop'>Sally's Sweet Shop</div><div class='icon_Container "+((shopListAlerts['sallys_sweet_shop']['cam'] == 0) ? '' : 'marked')+"' id='sallys_sweet_shop-cam'><div class='sec_Icon'></div><div class="+((apiData['shoplifting']['sallys_sweet_shop'][0]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['sallys_sweet_shop'][0]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div><div class='icon_Container2'><div class='sec_Icon blank'></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(170, 170, 170); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div></div></div>"

                    shopsHTML += "<div class='shop_Status'><div class='shop_Name' id='Bits_n_bobs'>Bits 'n' Bobs</div><div class='icon_Container "+((shopListAlerts['Bits_n_bobs']['cam'] == 0) ? '' : 'marked')+"' id='Bits_n_bobs-cam'><div class='sec_Icon two_Camera'></div><div class="+((apiData['shoplifting']['Bits_n_bobs'][0]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['Bits_n_bobs'][0]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div><div class='icon_Container2'><div class='sec_Icon blank'></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(170, 170, 170); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div></div></div>"

                    shopsHTML += "<div class='shop_Status'><div class='shop_Name "+((shopListAlerts['tc_clothing']['both'] == 0) ? '' : 'marked')+"' id='tc_clothing-both'>TC Clothing</div><div class='icon_Container "+((shopListAlerts['tc_clothing']['cam'] == 0) ? '' : 'marked')+"' id='tc_clothing-cam'><div class='sec_Icon one_Camera'></div><div class="+((apiData['shoplifting']['tc_clothing'][0]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['tc_clothing'][0]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div><div class='icon_Container2 "+((shopListAlerts['tc_clothing']['guard'] == 0) ? '' : 'marked')+"' id='tc_clothing-guard'><div class='sec_Icon checkpoint'></div><div class="+((apiData['shoplifting']['tc_clothing'][1]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['tc_clothing'][1]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div></div></div>"

                    shopsHTML += "<div class='shop_Status'><div class='shop_Name "+((shopListAlerts['super_store']['both'] == 0) ? '' : 'marked')+"' id='super_store-both'>Super Store</div><div class='icon_Container "+((shopListAlerts['super_store']['cam'] == 0) ? '' : 'marked')+"' id='super_store-cam'><div class='sec_Icon two_Camera'></div><div class="+((apiData['shoplifting']['super_store'][0]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['super_store'][0]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div><div class='icon_Container2 "+((shopListAlerts['super_store']['guard'] == 0) ? '' : 'marked')+"' id='super_store-guard'><div class='sec_Icon checkpoint'></div><div class="+((apiData['shoplifting']['super_store'][1]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['super_store'][1]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div></div></div>"

                    shopsHTML += "<div class='shop_Status'><div class='shop_Name "+((shopListAlerts['pharmacy']['both'] == 0) ? '' : 'marked')+"' id='pharmacy-both'>Pharmacy</div><div class='icon_Container "+((shopListAlerts['pharmacy']['cam'] == 0) ? '' : 'marked')+"' id='pharmacy-cam'><div class='sec_Icon three_Camera'></div><div class="+((apiData['shoplifting']['pharmacy'][0]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['pharmacy'][0]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div><div class='icon_Container2 "+((shopListAlerts['pharmacy']['guard'] == 0) ? '' : 'marked')+"' id='pharmacy-guard'><div class='sec_Icon checkpoint'></div><div class="+((apiData['shoplifting']['pharmacy'][1]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['pharmacy'][1]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div></div></div>"

                    shopsHTML += "<div class='shop_Status'><div class='shop_Name "+((shopListAlerts['cyber_force']['both'] == 0) ? '' : 'marked')+"' id='cyber_force-both'>Cyber Force</div><div class='icon_Container "+((shopListAlerts['cyber_force']['cam'] == 0) ? '' : 'marked')+"' id='cyber_force-cam'><div class='sec_Icon two_Camera'></div><div class="+((apiData['shoplifting']['cyber_force'][0]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['cyber_force'][0]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div><div class='icon_Container2 "+((shopListAlerts['cyber_force']['guard'] == 0) ? '' : 'marked')+"' id='cyber_force-guard'><div class='sec_Icon one_Guard'></div><div class="+((apiData['shoplifting']['cyber_force'][1]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['cyber_force'][1]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div></div></div>"

                    shopsHTML += "<div class='shop_Status'><div class='shop_Name "+((shopListAlerts['jewelry_store']['both'] == 0) ? '' : 'marked')+"' id='jewelry_store-both'>Jewelry Store</div><div class='icon_Container "+((shopListAlerts['jewelry_store']['cam'] == 0) ? '' : 'marked')+"' id='jewelry_store-cam'><div class='sec_Icon three_Camera'></div><div class="+((apiData['shoplifting']['jewelry_store'][0]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['jewelry_store'][0]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div><div class='icon_Container2 "+((shopListAlerts['jewelry_store']['guard'] == 0) ? '' : 'marked')+"' id='jewelry_store-guard'><div class='sec_Icon one_Guard'></div><div class="+((apiData['shoplifting']['jewelry_store'][1]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['jewelry_store'][1]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div></div></div>"

                    shopsHTML += "<div class='shop_Status'><div class='shop_Name "+((shopListAlerts['big_als']['both'] == 0) ? '' : 'marked')+"' id='big_als-both'>Big Al's Gun Shop</div><div class='icon_Container "+((shopListAlerts['big_als']['cam'] == 0) ? '' : 'marked')+"' id='big_als-cam'><div class='sec_Icon four_Camera'></div><div class="+((apiData['shoplifting']['big_als'][0]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['big_als'][0]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div><div class='icon_Container2 "+((shopListAlerts['big_als']['guard'] == 0) ? '' : 'marked')+"' id='big_als-guard'><div class='sec_Icon two_Guard'></div><div class="+((apiData['shoplifting']['big_als'][1]['disabled'] == false) ? '_active' : '_disabled')+"></div><svg class='circle' viewBox='0 0 100 100' data-test-id='CircularProgressbar'><path d='M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb(226, 226, 226); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path><path d=' M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94' stroke-width='6' fill-opacity='0' style='stroke: rgb("+((apiData['shoplifting']['big_als'][1]['disabled'] == false) ? '170, 170, 170' : '85, 168, 47')+"); stroke-linecap: butt; stroke-dasharray: 295.31px, 295.31px; stroke-dashoffset: 0px;'></path></svg></div></div></div>"

                    $("div[class*='shop_List']").html(shopsHTML);

                    var aString = ""
                    $.each(shopListAlerts, function(i, v){
                        $.each(this, function(index, value){
                            if(index == 'both'){
                                if(value == 1 && apiData['shoplifting'][i][0]['disabled'] == true && apiData['shoplifting'][i][1]['disabled'] == true){
                                    if(shopListAlerts[i]['bothSeenAt'] == 0 || Date.now() >= shopListAlerts[i]['bothSeenAt'] + (60 * 60 * 1000)){
                                        aString += shopListAlerts[i]['name']+' Cam and Guard/Checkpoint Down\n'
                                        shopListAlerts[i]['bothSeenAt'] = Date.now()
                                        localStorage.shopListAlerts = JSON.stringify(shopListAlerts)
                                    }
                                }
                            }
                            if(index == 'cam' && shopListAlerts[i]['bothSeenAt'] != Date.now()){
                                if(value == 1 && apiData['shoplifting'][i][0]['disabled'] == true){
                                    if(shopListAlerts[i]['camSeenAt'] == 0 || Date.now() >= shopListAlerts[i]['camSeenAt'] + (60 * 60 * 1000)){
                                        aString += shopListAlerts[i]['name']+' Cam Down\n'
                                        shopListAlerts[i]['camSeenAt'] = Date.now()
                                        localStorage.shopListAlerts = JSON.stringify(shopListAlerts)
                                    }
                                }
                            }
                            if(index == 'guard' && shopListAlerts[i]['bothSeenAt'] != Date.now()){
                                if(value == 1 && apiData['shoplifting'][i][1]['disabled'] == true){
                                    if(shopListAlerts[i]['guardSeenAt'] == 0 || Date.now() >= shopListAlerts[i]['guardSeenAt'] + (60 * 60 * 1000)){
                                        aString += shopListAlerts[i]['name']+' Guard/Checkpoint Down\n'
                                        shopListAlerts[i]['guardSeenAt'] = Date.now()
                                        localStorage.shopListAlerts = JSON.stringify(shopListAlerts)
                                    }
                                }
                            }
                        })
                    })

                    if(aString.length > 0){
                        audio()
                        setTimeout(function(){
                            if(confirm(aString)){
                                document.location = 'https://www.torn.com/loader.php?sid=crimes#/shoplifting'
                            }
                        }, 200)
                    }

                    $(".icon_Container, .icon_Container2:not(:has(.blank))").on('click', function(e){
                        shopListAlerts[e.currentTarget.id.split('-')[0]][e.currentTarget.id.split('-')[1]] == 0 ? (shopListAlerts[e.currentTarget.id.split('-')[0]][e.currentTarget.id.split('-')[1]] = 1, $(e.currentTarget).addClass('marked')): (shopListAlerts[e.currentTarget.id.split('-')[0]][e.currentTarget.id.split('-')[1]] = 0, $(e.currentTarget).removeClass('marked'))
                        localStorage.shopListAlerts = JSON.stringify(shopListAlerts)
                    })
                    $(".shop_Name:not('#sallys_sweet_shop, #Bits_n_bobs')").on('click', function(e){
                        shopListAlerts[e.currentTarget.id.split('-')[0]][e.currentTarget.id.split('-')[1]] == 0 ? (shopListAlerts[e.currentTarget.id.split('-')[0]][e.currentTarget.id.split('-')[1]] = 1, $(e.currentTarget).addClass('marked')): (shopListAlerts[e.currentTarget.id.split('-')[0]][e.currentTarget.id.split('-')[1]] = 0, $(e.currentTarget).removeClass('marked'))
                        localStorage.shopListAlerts = JSON.stringify(shopListAlerts)
                    })
                }
            })
        }
    }
}

function audio(){
    var audioPlayer = document.createElement('audio');
    audioPlayer.src = 'https://www.torn.com/casino/craps/audio/win.ogg';
    audioPlayer.preload = 'auto';
    audioPlayer.play()
}

$(".section_Header").on('click', function(e){
    $('.shop_List').toggle();
    if(localStorage.shopListVis=='grid'){
        localStorage.shopListVis = 'none'
    }else{
        localStorage.shopListVis = 'grid'
    }
})

getShop()
setInterval(getShop, 60000);