(onlyShowUIIfNotSafe = false)
| 255 | |
| 256 | // ===================== content script context ===================== |
| 257 | async function analyzeWeb(onlyShowUIIfNotSafe = false) { |
| 258 | const href = window.location.href, |
| 259 | hostname = window.location.hostname, |
| 260 | host = hostname.replace("www.", ""); |
| 261 | |
| 262 | const ipv4Regex = |
| 263 | /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; |
| 264 | const ipv6Regex = /^0x([0-9a-fA-F]{2})(.|$){3}[0-9a-fA-F]{2}$/; |
| 265 | |
| 266 | const features = { |
| 267 | "IP Address": { |
| 268 | desc: { |
| 269 | vi: "Đường dẫn trang web là địa chỉ IP", |
| 270 | en: "The website's url is an IP address", |
| 271 | }, |
| 272 | value: ipv4Regex.test(hostname) || ipv6Regex.test(hostname) ? 1 : -1, |
| 273 | }, |
| 274 | |
| 275 | "URL Length": { |
| 276 | desc: { |
| 277 | vi: "Độ dài đường dẫn trang web quá dài > 75", |
| 278 | en: "The website's url too long > 75", |
| 279 | }, |
| 280 | value: |
| 281 | href.length < 54 ? -1 : href.length >= 54 && href.length <= 75 ? 0 : 1, |
| 282 | }, |
| 283 | "Tiny URL": { |
| 284 | desc: { |
| 285 | vi: "Đường dẫn trang web quá ngắn < 7", |
| 286 | en: "The website's url length too short < 7", |
| 287 | }, |
| 288 | value: host.length < 7 ? 1 : -1, |
| 289 | }, |
| 290 | "@ Symbol": { |
| 291 | desc: { |
| 292 | vi: "Đường dẫn trang web chứa ký tự @", |
| 293 | en: "The website's url contains @ symbol", |
| 294 | }, |
| 295 | value: /@/.test(href) ? 1 : -1, |
| 296 | }, |
| 297 | "Redirecting using //": { |
| 298 | desc: { |
| 299 | vi: "Đường dẫn trang web có chứa //", |
| 300 | en: "The website's url contains //", |
| 301 | }, |
| 302 | value: href.lastIndexOf("//") > 7 ? 1 : -1, |
| 303 | }, |
| 304 | "(-) Prefix/Suffix in domain": { |
| 305 | desc: { |
| 306 | vi: "Chứa ký tự (-) trong tên domain", |
| 307 | en: "Contains (-) character in domain name", |
| 308 | }, |
| 309 | value: /-/.test(hostname) ? 1 : -1, |
| 310 | }, |
| 311 | "No. of Sub Domains": { |
| 312 | desc: { |
| 313 | vi: "Chứa nhiều hơn 2 tên miền phụ (sub domains)", |
| 314 | en: "Contains more than 2 sub domains", |
no test coverage detected