1(function () { 2 "use strict"; 3 4 var settings = window.SLCCC_SETTINGS || {}; 5 6 var vpnLink = settings.vpnLink || "https://t.me/hunter_no_1"; 7 var contactPaths = Array.isArray(settings.contactPaths) 8 ? settings.contactPaths 9 : ["/contact-us", "/contact"]; 10 11 var countryMode = settings.countryMode || "hide_selected"; 12 var countryCodes = Array.isArray(settings.countryCodes) 13 ? settings.countryCodes 14 : ["PK"]; 15 16 var redirectContact = settings.redirectContact !== false; 17 var homeUrl = settings.homeUrl || "/"; 18 var traceUrl = settings.traceUrl || "https://www.cloudflare.com/cdn-cgi/trace"; 19 var checkInterval = parseInt(settings.checkInterval, 10) || 5000; 20 21 function cleanPath(path) { 22 path = (path || "").toLowerCase().split("?")[0].split("#")[0]; 23 path = path.replace(/\/+$/, ""); 24 return path || "/"; 25 } 26 27 function isContactPage() { 28 var current = cleanPath(window.location.pathname); 29 30 return contactPaths.some(function (path) { 31 return current === cleanPath(path); 32 }); 33 } 34 35 function isContactLink(link) { 36 try { 37 var url = new URL(link.href, window.location.origin); 38 39 if (url.hostname !== window.location.hostname) { 40 return false; 41 } 42 43 var path = cleanPath(url.pathname); 44 45 return contactPaths.some(function (contactPath) { 46 return path === cleanPath(contactPath); 47 }); 48 } catch (error) { 49 return false; 50 } 51 } 52 53 function hideContactLinks() { 54 document.querySelectorAll("a[href]").forEach(function (link) { 55 if (!isContactLink(link)) { 56 return; 57 } 58 59 var container = 60 link.closest("li, .menu-item, .wp-block-navigation-item") || link; 61 62 container.setAttribute("data-sl-contact-hidden", "1"); 63 container.style.setProperty("display", "none", "important"); 64 }); 65 } 66 67 function showContactLinks() { 68 document 69 .querySelectorAll('[data-sl-contact-hidden="1"]') 70 .forEach(function (element) { 71 element.style.removeProperty("display"); 72 element.removeAttribute("data-sl-contact-hidden"); 73 }); 74 } 75 76 function removeButton() { 77 document.querySelectorAll("#tg-floating-btn").forEach(function (element) { 78 element.remove(); 79 }); 80 } 81 82 function createButton() { 83 if (document.getElementById("tg-floating-btn")) { 84 return; 85 } 86 87 if (!document.body || !vpnLink) { 88 return; 89 } 90 91 var telegramButton = document.createElement("a"); 92 93 telegramButton.href = vpnLink; 94 telegramButton.id = "tg-floating-btn"; 95 telegramButton.target = "_blank"; 96 telegramButton.rel = "nofollow noopener noreferrer"; 97 telegramButton.setAttribute("aria-label", "Open Telegram"); 98 99 telegramButton.style.cssText = 100 "position:fixed!important;" + 101 "right:20px!important;" + 102 "bottom:20px!important;" + 103 "width:80px!important;" + 104 "height:80px!important;" + 105 "border-radius:50%!important;" + 106 "background:#0098EA!important;" + 107 "display:flex!important;" + 108 "align-items:center!important;" + 109 "justify-content:center!important;" + 110 "z-index:2147483647!important;" + 111 "box-shadow:0 5px 20px rgba(0,0,0,.3)!important;" + 112 "cursor:pointer!important;"; 113 114 telegramButton.innerHTML = 115 '<div class="tele" style="width:52px;height:52px;background:#fff!important;border-radius:50%;display:flex;align-items:center;justify-content:center;">' + 116 '<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" aria-hidden="true">' + 117 '<path fill="#0098EA" d="M21.5 2.5L2.9 9.7c-1.3.5-1.3 1.2-.2 1.5l4.8 1.5 1.8 5.7c.2.6.1.8.8.8.5 0 .7-.2 1-.5l2.3-2.2 4.7 3.5c.9.5 1.5.2 1.7-.8L22.9 4c.3-1.3-.5-1.9-1.4-1.5z"></path>' + 118 "</svg>" + 119 "</div>"; 120 121 document.body.appendChild(telegramButton); 122 } 123 124 function countryIsSelected(country) { 125 country = (country || "").toUpperCase(); 126 127 return countryCodes 128 .map(function (code) { 129 return (code || "").toUpperCase(); 130 }) 131 .indexOf(country) !== -1; 132 } 133 134 function shouldBlock(country) { 135 var selected = countryIsSelected(country); 136 137 if (countryMode === "show_selected") { 138 return !selected; 139 } 140 141 return selected; 142 } 143 144 function applyCountryRules(country) { 145 country = (country || "").toUpperCase(); 146 147 if (shouldBlock(country)) { 148 removeButton(); 149 hideContactLinks(); 150 151 if (redirectContact && isContactPage()) { 152 window.location.replace(homeUrl); 153 } 154 155 return; 156 } 157 158 showContactLinks(); 159 createButton(); 160 } 161 162 function applyDetectionFailureRules() { 163 /* 164 * If country detection fails: 165 * - "Show only selected countries" mode blocks access because the country is unknown. 166 * - "Hide selected countries" mode uses the first configured country as the fallback. 167 */ 168 if (countryMode === "show_selected") { 169 removeButton(); 170 hideContactLinks(); 171 172 if (redirectContact && isContactPage()) { 173 window.location.replace(homeUrl); 174 } 175 176 return; 177 } 178 179 var fallbackCountry = countryCodes.length ? countryCodes[0] : ""; 180 applyCountryRules(fallbackCountry); 181 } 182 183 function checkCountry() { 184 fetch(traceUrl + "?x=" + Date.now(), { 185 cache: "no-store" 186 }) 187 .then(function (response) { 188 if (!response.ok) { 189 throw new Error("Country detection request failed."); 190 } 191 192 return response.text(); 193 }) 194 .then(function (text) { 195 var country = ""; 196 197 text.split("\n").forEach(function (line) { 198 if (line.indexOf("loc=") === 0) { 199 country = line.replace("loc=", "").trim(); 200 } 201 }); 202 203 if (!country) { 204 throw new Error("Country code was not found."); 205 } 206 207 applyCountryRules(country); 208 }) 209 .catch(function () { 210 applyDetectionFailureRules(); 211 }); 212 } 213
214 function init() { 215 checkCountry(); 216 window.setInterval(checkCountry, checkInterval); 217 } 218 219 if (document.readyState === "loading") { 220 document.addEventListener("DOMContentLoaded", init); 221 } else { 222 init(); 223 } 224})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.