PageSourceSearch

https://kara07.github.io/live2d/js/message.js

js kara07.github.io collected 2026-10-03 09:26:42 UTC 5,508 bytes, 141 lines download raw bytes

1function renderTip(template, context) {
2    var tokenReg = /(\\)?\{([^\{\}\\]+)(\\)?\}/g;
3    return template.replace(tokenReg, function (word, slash1, token, slash2) {
4        if (slash1 || slash2) {
5            return word.replace('\\', '');
6        }
7        var variables = token.replace(/\s/g, '').split('.');
8        var currentObject = context;
9        var i,
10            length,
11            variable;
12        for (i = 0, length = variables.length; i < length; ++i) {
13            variable = variables[i];
14            currentObject = currentObject[variable];
15            if (currentObject === undefined || currentObject === null) return '';
16        }
17        return currentObject;
18    });
19}
20
21String.prototype.renderTip = function (context) {
22    return renderTip(this, context);
23};
24
25var re = /x/;
26console.log(re);
27re.toString = function () {
28    showMessage('哈哈,你打开了控制台,是想要看看我的秘密吗?', 5000);
29    return '';
30};
31
32$(document).on('copy', function () {
33    showMessage('你都复制了些什么呀,转载要记得加上出处哦~~', 5000);
34});
35
36function initTips() {
37    $.ajax({
38        cache: true,
39        url: `${message_Path}message.json`,
40        dataType: "json",
41        success: function (result) {
42            $.each(result.mouseover, function (index, tips) {
43                $(tips.selector).mouseover(function () {
44                    var text = tips.text;
45                    if (Array.isArray(tips.text)) text = tips.text[Math.floor(Math.random() * tips.text.length + 1) - 1];
46                    text = text.renderTip({text: $(this).text()});
47                    showMessage(text, 3000);
48                });
49            });
50            $.each(result.click, function (index, tips) {
51                $(tips.selector).click(function () {
52                    var text = tips.text;
53                    if (Array.isArray(tips.text)) text = tips.text[Math.floor(Math.random() * tips.text.length + 1) - 1];
54                    text = text.renderTip({text: $(this).text()});
55                    showMessage(text, 3000);
56                });
57            });
58        }
59    });
60}
61
62initTips();
63
64(function () {
65    var text;
66    if (document.referrer !== '') {
67        var referrer = document.createElement('a');
68        referrer.href = document.referrer;
69        text = '嗨!来自 <span style="color:#0099cc;">' + referrer.hostname + '</span> 的朋友!';
70        var domain = referrer.hostname.split('.')[1];
71        if (domain == 'baidu') {
72            text = '嗨! 来自 百度搜索 的朋友!<br>欢迎访问<span style="color:#0099cc;">「 ' + document.title.split(' - ')[0] + ' 」</span>';
73        } else if (domain == 'so') {
74            text = '嗨! 来自 360搜索 的朋友!<br>欢迎访问<span style="color:#0099cc;">「 ' + document.title.split(' - ')[0] + ' 」</span>';
75        } else if (domain == 'google') {
76            text = '嗨! 来自 谷歌搜索 的朋友!<br>欢迎访问<span style="color:#0099cc;">「 ' + document.title.split(' - ')[0] + ' 」</span>';
77        }
78    } else {
79        if (window.location.href == `${home_Path}`) { //主页URL判断,需要斜杠结尾
80            var now = (new Date()).getHours();
81            if (now > 23 || now <= 5) {
82                text = '你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?';
83            } else if (now > 5 && now <= 7) {
84                text = '早上好!一日之计在于晨,美好的一天就要开始了!';
85            } else if (now > 7 && now <= 11) {
86                text = '上午好!工作顺利嘛,不要久坐,多起来走动走动哦!';
87            } else if (now > 11 && now <= 14) {
88                text = '中午了,工作了一个上午,现在是午餐时间!';
89            } else if (now > 14 && now <= 17) {
90                text = '午后很容易犯困呢,今天的运动目标完成了吗?';
91            } else if (now > 17 && now <= 19) {
92                text = '傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~~';
93            } else if (now > 19 && now <= 21) {
94                text = '晚上好,今天过得怎么样?';
95            } else if (now > 21 && now <= 23) {
96                text = '已经这么晚了呀,早点休息吧,晚安~~';
97            } else {
98                text = '嗨~ 快来逗我玩吧!';
99            }
100        } else {
101            text = '欢迎阅读<span style="color:#0099cc;">「 ' + document.title.split(' - ')[0] + ' 」</span>';
102        }
103    }
104    showMessage(text, 12000);
105})();
106
107window.setInterval(showHitokoto, 30000);
108
109function showHitokoto() {
110    $.getJSON("https://v1.hitokoto.cn/", function (result) {
111        showMessage(result.hitokoto, 5000);
112    });
113}
114
115function showMessage(text, timeout) {
116    if (Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1) - 1];
117    //console.log('showMessage', text);
118    $('.message').stop();
119    $('.message').html(text).fadeTo(200, 1);
120    if (timeout === null) timeout = 5000;
121    hideMessage(timeout);
122}
123
124function hideMessage(timeout) {
125    $('.message').stop().css('opacity', 1);
126    if (timeout === null) timeout = 5000;
127    $('.message').delay(timeout).fadeTo(200, 0);
128}
129
130function initLive2d() {
131    $('.hide-button').fadeOut(0).on('click', () => {
132        $('#landlord').css('display', 'none')
133    })
134    $('#landlord').hover(() => {
135        $('.hide-button').fadeIn(600)
136    }, () => {
137        $('.hide-button').fadeOut(600)
138    })
139}
140
141initLive2d();

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.