diff --git a/Scriptable-JS/ShorteNB-Core.js b/Scriptable-JS/ShorteNB-Core.js index 865ae20..54e7acf 100644 --- a/Scriptable-JS/ShorteNB-Core.js +++ b/Scriptable-JS/ShorteNB-Core.js @@ -6,12 +6,12 @@ let MNC2 = MNC2; let user = "username"; let password = "password"; -var eNB, acteNB, CID, band, actMNC, cookies = ""; +var eNB, acteNB, CID, band, actMNC, cookies, MNO = ""; // eNB/CID Calculation eNB = Math.floor(CellID / 256); -acteNB = eNB; +acteNB = eNB CID = CellID % 256; // Band Determination @@ -20,25 +20,29 @@ if (eNB >= 10000 && eNB <= 99999) { // Vodafone band = [,20,,3,1,7,28,,,8,,20,,3,1,7][~~(CID / 10)]; actMNC = 22210; + MNO = "Vodafone"; } else if (eNB >= 100000 && eNB <= 999999) { if (MNC1 == 22288 || MNC2 == 22288) { - actMNC = 22288; + actMNC = 22288 + MNO = "WindTre"; if (eNB >= 502000 && Math.floor(eNB/1000) % 2 != 0) { - eNB -= 401000; - } else if (eNB >= 502000) { - eNB -= 400000; + eNB -= 401000 + } else if (eNB >= 502000) { + eNB -= 400000 } else if (Math.floor(eNB/1000) % 2 != 0) { eNB -= 1000; - } + } // WindTre band = [3,20,7,1,38][~~(CID / 6)]; } else { - actMNC = 2221; + actMNC = 2221 + MNO = "Tim"; // Tim - band = [,,7,1,3,,20][~~(CID / 10)]; + band = [,,7,1,3,,20,28,,,,,7,1,3][~~(CID / 10)]; } } else if(eNB >= 1000000 && eNB <= 1100000) { actMNC = 22250; + MNO = "iliad"; // iliad band = [,,1,,"7 COVID",,7,28,3][~~(CID / 10)]; } @@ -64,6 +68,6 @@ if (Keychain.contains("cookie") == false) { // Return data required by ShorteNB -return{eNB, acteNB, CID, band, actMNC}; +return{eNB, acteNB, CID, band, actMNC, MNO}; Script.complete(); \ No newline at end of file diff --git a/Scriptable-JS/lteitaly-query.js b/Scriptable-JS/lteitaly-query.js index c660e55..602aca4 100644 --- a/Scriptable-JS/lteitaly-query.js +++ b/Scriptable-JS/lteitaly-query.js @@ -13,11 +13,9 @@ req.method = "POST"; req.headers = { "Content-Type": "application/json;charset=UTF-8", "Cookie": cookies, "Referer": "https://lteitaly.it" }; req.body = "[\"databyenb3\",\"actMNC\",\"eNB\"]"; -//Check if cookie has expired, if it has update it and quit the shortcut if(await req.loadString() != "Forbidden") { let json = await req.loadJSON(); - // Process and Update Cookie req.response.cookies; @@ -38,19 +36,15 @@ if(await req.loadString() != "Forbidden") { let associateIndex = ["- AAU mmWave","- TDD Sub-6GHz","- FDD","- DSS","- Altro"]; let associateDigit = ["No","","Passivo","Intersite","-","Ignoto"]; let NR_Info = [...json[3]].map((it, index) => [associateIndex[index], associateDigit[it]]).filter(it => it[1] !== 'No').map(it => it.join(" ")).join("\n") - return{Name,LTE_Bands,NR_Bands,NR_Info}; Script.complete(); } else { - - //Update expired cookie let user = "username"; let password = "password"; - let loginReq = new Request("https://lteitaly.it/api/AV1.php"); loginReq.method = "POST"; loginReq.headers = { "Content-Type": "application/json;charset=UTF-8" }; - loginReq.body = "[\"login\",\""+ user +"\",\"" + password +"\",true]";; + loginReq.body = "[\"login\",\""+ user +"\",\""+ password +"\",true]";; await loginReq.load(); loginReq.response.cookies; @@ -60,6 +54,6 @@ if(await req.loadString() != "Forbidden") { newcookies += cookie.name + "=" + cookie.value + "; "; } - Keychain.set("cookie", newcookies); + Keychain.set("cookie",newcookies); Script.complete(); } \ No newline at end of file diff --git a/ShorteNB.shortcut b/ShorteNB.shortcut index e902216..6d3a5fa 100644 Binary files a/ShorteNB.shortcut and b/ShorteNB.shortcut differ diff --git a/changelog b/changelog index 4ea86ab..6391dbb 100644 --- a/changelog +++ b/changelog @@ -1,2 +1,2 @@ -Corretto l'error handling in caso di cookie scaduti e cambiato il metodo in cui vengono salvate le impostazioni in modo da non salvarle in chiaro. È possibile cancellare il file settings.json da iCloud Drive. -Sarà necessario effettuare nuovamente il primo setup dello Shortcut. \ No newline at end of file +Modifica minore al salvataggio delle credenziali. Sarà necessario effettuare nuovamente il primo setup dello Shortcut (giuro che sarà l'ultima volta) o eseguire Keychain.set("setup","true") dentro Scriptable. +Aggiunti i CID della B28 e i CID 1xx di Tim, modificato l'ordine di esecuzione per rendere più efficiente l'esecuzione quando il GPS fa fatica a localizzare il telefono, aggiunta l'indicazione dell'MNO rilevato nella notifica. diff --git a/link b/link index 1021e97..8d73634 100644 --- a/link +++ b/link @@ -1 +1 @@ -https://www.icloud.com/shortcuts/82434d4911f94103862e22d67325ef53 \ No newline at end of file +https://www.icloud.com/shortcuts/85691dedefa641eb865352e102284e76 \ No newline at end of file diff --git a/version b/version index b123147..8cfbc90 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.1 \ No newline at end of file +1.1.1 \ No newline at end of file