PageSourceSearch

https://hoshino-yumetsuki.github.io/js/welcome.js

js hoshino-yumetsuki.github.io collected 2026-10-03 09:18:40 UTC 1,864 bytes, 75 lines download raw bytes

1// 欢迎提示处理
2
3// 浏览器版本检测优化
4const BROWSER_VERSION_LIMITS = {
5  Edge: 90,
6  Firefox: 90,
7  OPR: 80,
8  Chrome: 90,
9  Safari: null // Safari 暂不处理
10}
11
12const getBrowserInfo = () => {
13  const ua = navigator.userAgent
14  for (const [browser] of Object.entries(BROWSER_VERSION_LIMITS)) {
15    if (ua.includes(browser)) {
16      const match = ua.match(new RegExp(`${browser}\\/([\\d]+)`))
17      return { browser, version: match ? parseInt(match[1]) : 0 }
18    }
19  }
20  return null
21}
22
23const browserVersion = () => {
24  const browserInfo = getBrowserInfo()
25  if (!browserInfo) return
26
27  const minVersion = BROWSER_VERSION_LIMITS[browserInfo.browser]
28  if (minVersion && browserInfo.version < minVersion) {
29    Snackbar.show({
30      text: "浏览器版本较低,网站样式可能错乱",
31      actionText: "关闭",
32      duration: "6000",
33      pos: "bottom-right"
34    })
35  }
36}
37
38// Cookie 相关函数优化
39const setCookies = (obj, limitTime) => {
40  const expires = new Date(Date.now() + limitTime * 24 * 60 * 60 * 1000).toGMTString()
41  Object.entries(obj).forEach(([key, value]) => {
42    document.cookie = `${key}=${value};expires=${expires}`
43  })
44}
45
46const getCookie = (name) => {
47  const match = document.cookie.match(new RegExp(`(^| )${name}=([^;]*)(;|$)`))
48  return match ? decodeURIComponent(match[2]) : null
49}
50
51/*
52if (sessionStorage.getItem('popCookieWindow') != '0') {
53  setTimeout(function () {
54    Snackbar.show({
55      text: '本站使用Cookie和本地/会话存储保证浏览体验和网站统计',
56      pos: 'bottom-right',
57      actionText: '查看博客声明',
58      onActionClick: function (element) {
59        window.open('/license')
60      }
61    })
62  }, 3000)
63}
64sessionStorage.setItem('popCookieWindow', '0')
65*/
66
67if (getCookie("browsertc") != 1) {
68  setCookies(
69    {
70      browsertc: 1
71    },
72    1
73  )
74  browserVersion()
75}

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.