PageSourceSearch

https://clashnode.github.io/assets/website/js/frontend/G.js

js clashnode.github.io collected 2026-10-03 08:48:20 UTC 7,328 bytes, 228 lines download raw bytes

1// JavaScript Document
2(function (_w) {
3
4    var w = _w;
5
6    //main namespace
7    G = {};
8	G.page_code = 'index';
9	G.Message = {
10		error:'系统错误,请联系管理员处理'
11	};
12
13	
14    G.Fun = {
15		//获取url中的参数
16		getUrlParam: function(name) {
17		    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
18		    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
19		    if (r != null) return unescape(r[2]); return null; //返回参数值
20		},
21    	Today: function(){
22    		return G.Fun.formatter_date();	
23    	},
24	    addDay: function(date, num) {
25	      // 创建一个新的 Date 对象,避免直接修改原日期对象
26	      var newDate = new Date(date.getTime());
27	      // 获取当前日期的天数并加一
28	      var day = newDate.getDate();
29	      newDate.setDate(day + num);
30	      return G.Fun.formatter_date(newDate);
31	    },
32    	formatter_date: function(time){
33			const date = typeof time == 'undefined' ? new Date() : new Date(time);
34			const formattedDate = date.toLocaleString('zh-CN', { year: 'numeric', month: 'numeric', day: 'numeric' });
35			
36			return formattedDate;
37    	},
38    	formatter_date_to_items: function(time) {
39    		var d = G.Fun.formatter_date(time);
40    		var dSplit = d.split('/');
41    		var year = dSplit[0];
42    		var month = dSplit[1].length == 1 ? '0' + dSplit[1] : dSplit[1];
43    		var day = dSplit[2].length == 1 ? '0' + dSplit[2] : dSplit[2];
44
45    		var re = {
46    			year: year,
47    			month: month,
48    			day: day
49    		};
50    		return re
51    	},
52    	check_invite_url: function(url, type){
53    		if (typeof G_Invite_config != 'undefined')
54    		{
55    			var flag = true;
56    			var index = G_Invite_config['url_urls']['key'].indexOf(url);
57    			if (index > -1)
58    			{
59    				url = G_Invite_config['url_urls']['value'][index];
60    				flag = false;
61    			}
62
63    			if (flag)
64    			{
65	    			if (typeof G_Invite_config['code_urls'][type] != 'undefined')
66	    			{
67	    				url = G_Invite_config['code_urls'][type];
68	    				flag = false;
69	    			}
70	    		}
71    		}
72    		return url;
73    	},
74    	check_invite_code: function(code, type){
75    		if (typeof G_Invite_config != 'undefined')
76    		{
77    			if (typeof G_Invite_config['codes'][type] != 'undefined')
78    			{
79    				var new_code = G_Invite_config['codes'][type];
80    				code = new_code.length == '' ? code : new_code;
81    			}
82    		}
83    		return code;
84    	},
85    	CreateItem: function(time){
86    		var tempDate = G.Fun.formatter_date(time)
87    		tempDateSplit = tempDate.split('/');
88    		var title = tempDateSplit[1] + '月'+ tempDateSplit[2] +'日更新,'+tempDateSplit[0]+'年最新高速Shadowrocket/SSR/V2ray/Clash订阅链接免费节点订阅';
89    		var url = '/newly-discovered-nodes/index.html?date=' + tempDate.replace(/\//g, '-');
90    		var time = tempDateSplit[1] + '月'+ tempDateSplit[2] +'日';
91
92    		return {title: title, url: url, time: time};
93    	},
94    	BindData: function(datas, template) {
95    		$.each(datas, function(i){
96    			var item = datas[i];
97
98    			var template_temp = template.clone();
99    			template_temp.find('.xcblog-blog-title').text(item['title']);
100    			template_temp.find('.xcblog-blog-url').attr('href', item['url']);
101    			template_temp.find('.xcblog-blog-time').text(item['time']);
102
103    			$('.xcblog-blog-list').prepend(template_temp);
104    		})
105    	},
106    	BindTo: function(){
107    		$('.js_to').attr('href', 'javascript:;');
108	        $('.js_to').click(function(e){
109	        	e.preventDefault();
110
111	            var url = $(this).data('url');
112	            var code = $(this).data('code');
113	            var type = $(this).data('type');
114	            var new_url = G.Fun.check_invite_url(url, type);
115	            var new_code = G.Fun.check_invite_code(code, type);
116	            new_url += new_code;
117
118	            if (typeof $.post === 'function') {
119	            	var domain = 'https://www.freeclashnode.com';
120		            $.post(
121		            	domain + '/index.php/api/xcblog/c',
122		            	{
123		            		url: location.href,
124		            		to_url: new_url,
125		            		code: type,
126		            		ad_code: type
127		            	}
128		            );
129		        }
130
131	            window.open(new_url);
132	        })
133    	},
134    	BindDetailWebsite: function(){
135    		if ($('#share-website-info').length > 0)
136    		{
137	    		var name = $('#share-website-info').data('name');
138	    		var url = $('#share-website-info').data('url');
139
140	    		if (name != '' && url != '')
141	    		{
142	    			$.each($('h2:contains("订阅链接"), h2:contains("订阅文件链接")'), function(i){
143	    				var item = $('h2:contains("订阅链接"), h2:contains("订阅文件链接")').eq(i);
144	    				if (item.text() == '订阅链接' || item.text() == '订阅文件链接')
145	    				{
146	    					var div = $('<div style="background:#fcf8e3;border:1px solid #faf3cd;border-left: 0.5rem solid #faf3cd;padding: 0.5rem;line-height:2rem;margin-top: 1rem;color:#c09853;">以下订阅链接均来自 <b>'+name+'</b> 分享,更多免费机场订阅可 <a href="'+url+'">【跳转查看】</a></div>');
147	    					item.after(div);
148	    				}
149	    			})
150	    		}
151	    	}
152    	},
153        //初始化操作
154        init: function (page_code) {
155        	G.Fun.BindTo();
156			switch(page_code)
157			{
158				case 'index':
159				case 'category':
160					var first_item = $('.xcblog-blog-list .xcblog-blog-item:eq(0)');
161					var first_item_date = new Date(first_item.data('date'));
162
163					if (G.Fun.formatter_date() != G.Fun.formatter_date(first_item_date))
164					{
165						var datas = [];
166						for(var i=1;i<99;i++)
167						{
168							var the_date = G.Fun.addDay(first_item_date, i);
169							// console.log(the_date);
170
171							datas.push(G.Fun.CreateItem(the_date));
172
173							if (the_date == G.Fun.Today())
174							{
175								break;
176							}
177						}
178						// console.log(datas);
179						G.Fun.BindData(datas, first_item);
180					}
181					break;
182
183				case 'newly_discovered_nodes':
184					G.Fun.BindDetailWebsite();
185					
186					var date = G.Fun.getUrlParam('date');
187					dateItems = G.Fun.formatter_date_to_items(date);
188
189					var clash_rows = [];
190					var v2ray_rows = [];
191					for(var i=0;i<5;i++)
192					{
193						var clash_url = 'https://node.freeclashnode.com/uploads/'+dateItems['year']+'/'+dateItems['month']+'/'+i+'-'+dateItems['year']+dateItems['month']+dateItems['day']+'.yaml';
194						clash_rows.push(clash_url);
195
196						var v2ray_url = 'https://node.freeclashnode.com/uploads/'+dateItems['year']+'/'+dateItems['month']+'/'+i+'-'+dateItems['year']+dateItems['month']+dateItems['day']+'.txt';
197						v2ray_rows.push(v2ray_url);
198					}
199					var singbox_rows = ['https://node.freeclashnode.com/uploads/'+dateItems['year']+'/'+dateItems['month']+'/'+dateItems['year']+dateItems['month']+dateItems['day']+'.json'];
200
201					$.each(clash_rows, function(i){
202						var clash_p = $('<p>'+clash_rows[i]+'</p>')
203						$('.xcblog-clash-box').append(clash_p);
204						var v2ray_p = $('<p>'+v2ray_rows[i]+'</p>')
205						$('.xcblog-v2ray-box').append(v2ray_p);
206					})
207
208					$('.xcblog-singbox-box').html('<p>'+singbox_rows[0]+'</p>');
209					break;
210
211				case 'detail':
212					G.Fun.BindDetailWebsite();
213					break;
214			}
215        },
216    };
217
218    $(function () {
219		var page_code = $('body').attr('data-page');
220        G.Fun.init(page_code);
221    });
222	
223})();
224
225
226
227
228

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.