PageSourceSearch

https://046sp.com/js/cookie.js

js 046sp.com collected 2026-10-09 04:38:08 UTC 4,515 bytes, 125 lines download raw bytes

1//-----------------------------cookie------------------------------
2var cookie = {
3    //milliseconds remaining today
4    leftTime: function() {
5        var curTamp = new Date().getTime();
6        var curDate = new Date(); //191223 added
7        //The time stamp of the early morning of the day, minus one millisecond is to prevent the state that the subsequent time will not reach 00:00:00
8        var curWeeHours = new Date(curDate.toLocaleDateString()).getTime() - 1;
9        var passedTamp = curTamp - curWeeHours;
10        var leftTamp = 24 * 60 * 60 * 1000 - passedTamp;
11        return leftTamp;
12    },
13    //n: key name, v: key value, exp: expiration time (ms)
14    setCookie: function(n, v, exp) {
15        var date = new Date()
16        date.setTime(date.getTime() + exp);
17        document.cookie = n + "=" + escape(v) +
18            ((exp == null) ? "" : ";expires=" + date.toGMTString())
19    },
20    //n is the key name of the key value you want to get
21    getCookie: function(n) {
22        var reg = /\s/g;
23        var result = document.cookie.replace(reg, "");
24        var resultArr = result.split(";");
25        for (var i = 0; i < resultArr.length; i++) {
26            var nameArr = resultArr[i].split("=");
27            if (nameArr[0] == n) {
28                return nameArr[1];
29            }
30        }
31    }
32};
33  
34//generate the guid
35var guid = function() {
36    function S4() {
37        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
38    }
39    return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4());
40};
41  
42//If the guid does not exist, then generate the guid
43console.log(cookie.leftTime() / 1000 / 60 /60);
44!cookie.getCookie('guid') && cookie.setCookie('guid', guid(), cookie.leftTime());
45
46/*
47                   _ooOoo_
48                  o8888888o
49                  88" . "88
50                  (| -_- |)
51                  O\  =  /O
52               ____/`---'\____
53             .'  \\|     |//  `.
54            /  \\|||  :  |||//  \
55           /  _||||| -:- |||||-  \
56           |   | \\\  -  /// |   |
57           | \_|  ''\---/''  |   |
58           \  .-\__  `-`  ___/-. /
59         ___`. .'  /--.--\  `. . __
60      ."" '<  `.___\_<|>_/___.'  >'"".
61     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
62     \  \ `-.   \_ __\ /__ _/   .-` /  /
63======`-.____`-.___\_____/___.-`____.-'======
64                   `=---='
65^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66            佛祖保佑       永无BUG
67*/
68
69//20260831 
70/* ============================================================
71 * 底部「收藏本站」提示条 —— 关闭后一段时间内不再出现(全站版)
72 * 不用 Element.closest / matches,兼容老版 UC 与安卓内核。
73 * ============================================================ */
74(function () {
75	var NAME = 'dibu_closed';
76	var DAYS = 1;      // 可用小数:0.5 = 12 小时,0.25 = 6 小时
77
78	function cookieGet(name) {
79		var arr = (document.cookie || '').split(';');
80		for (var i = 0; i < arr.length; i++) {
81			var kv = arr[i].split('=');
82			if (kv[0].replace(/^\s+|\s+$/g, '') === name) { return kv[1] || ''; }
83		}
84		return '';
85	}
86	function cookieSet(name, val, days) {
87		var t = new Date();
88		t.setTime(t.getTime() + days * 86400000);
89		document.cookie = name + '=' + val + ';expires=' + t.toUTCString() + ';path=/';
90	}
91	function hasClass(n, c) {
92		return typeof n.className === 'string' && (' ' + n.className + ' ').indexOf(' ' + c + ' ') > -1;
93	}
94	function upMatch(node, test) {
95		for (var n = node; n && n !== document.documentElement; n = n.parentNode) {
96			if (n.nodeType === 1 && test(n)) { return n; }
97		}
98		return null;
99	}
100	function isBar(n) {
101		return n.id === 'download_dibu' || hasClass(n, 'global_video_bottom_dbtc');
102	}
103
104	// 已关闭过:尽早注入一条 CSS,避免提示条闪一下再消失
105	if (cookieGet(NAME) === '1') {
106		var st = document.createElement('style');
107		st.type = 'text/css';
108		st.appendChild(document.createTextNode(
109			'#download_dibu,.global_video_bottom_dbtc{display:none !important}'
110		));
111		(document.head || document.getElementsByTagName('head')[0] ||
112		 document.documentElement).appendChild(st);
113	}
114
115	// 捕获阶段挂在 document 上:提示条何时被注入都能接住,
116	// 且早于元素上的 onclick="closeAd()"
117	document.addEventListener('click', function (e) {
118		var btn = upMatch(e.target, function (n) {
119			return n.id === 'foot_down_close' || hasClass(n, 'aCloseBtn');
120		});
121		if (!btn) { return; }
122		if (!upMatch(btn, isBar)) { return; }
123		cookieSet(NAME, '1', DAYS);
124	}, true);
125})();

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.