| 67 | } |
| 68 | |
| 69 | function get_target_from_ua(useragent) { |
| 70 | const pattern = /^Mozilla\/5\.0 \(?(?:PlayStation; )?PlayStation (4|5)[ \/]([0-9]{1,2}\.[0-9]{2})\)? AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)(?: Version\/[0-9.]+ Safari\/[0-9.]+)?$/; |
| 71 | const match = pattern.exec(useragent); |
| 72 | if (!match) { |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | if (match[1] == "4") { |
| 77 | return parseInt(`0x0${match[2].replace(".", "").padStart(4, "0")}`); |
| 78 | } else if (match[1] == "5") { |
| 79 | return parseInt(`0x1${match[2].replace(".", "").padStart(4, "0")}`); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | export let target = null; |
| 84 | set_target(get_target_from_ua(navigator.userAgent)); |