-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadmin.js
597 lines (537 loc) · 16.1 KB
/
admin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
// ==UserScript==
// @name 博客园后台
// @namespace http://www.terwergreen.com/
// @version 0.0.1
// @description 博客园后台界面美化
// @author Terwer
// @match *://i.cnblogs.com/*
// @match *://i-import.cnblogs.com/*
// @grant GM_addStyle
// @require https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
// ==/UserScript==
console.log("New style of cnblogs admin desgined by Terwer!");
var config = {
blogName:'远方的灯塔',
author:'tangyouwei'
};
(function() {
'use strict';
// bootstrap4
addLinkCss('https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css');
console.log("add bootstrap4");
function addLinkCss(url){
var link = window.document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url;
document.getElementsByTagName("HEAD")[0].appendChild(link);
}
// ==============================================
// 自定义css
var cnblogsAdminCss = `
body{
margin: 0;
font-family: "Hiragino Sans GB","Microsoft Yahei",SimSun,Arial,"Helvetica Neue",Helvetica;
font-size: 12px;
line-height: 1.5;
padding: 0;
background-color: #F2F5F4;
}
button, input, optgroup, select, textarea {
margin: 0;
padding: 0;
border: 1px solid #ededed;
border-radius: 0;
font-family: "Hiragino Sans GB","Microsoft Yahei",SimSun,Arial,"Helvetica Neue",Helvetica;
}
a:link, a:visited, a:active {
color: #555 !important;
background-color: transparent !important;
}
a:hover{
color: #00B38A !important;
}
ul, ol {
margin: 0;
padding: 0;
list-style: none;
}
`;
// 顶部
cnblogsAdminCss += `
#top_nav{
background: #F2F5F4 !important;
height: 26px;
line-height: 26px;
font-size: 12px;
}
#top_nav #left a {
margin-left: 6px;
margin-right: 6px;
}
#blog_top_nav_block #site_nav{
padding-left: 4px;
}
#blog_top_nav_block #site_nav a{
margin-left: 6px;
}
`;
// 页面标题
cnblogsAdminCss += `
#SiteTitle h2{
font-size:24px;
font-weight: bold;
padding:0;
}
#SiteTitle h2 a{
color: #00B38A !important;
}
#blog_title h3{
font-size:20px;
font-weight: bold;
}
#blog_title h3 a{
color: #00B38A !important;
}
#BlogTitle h3{
font-size:20px;
font-weight: bold;
}
#BlogTitle h3 a{
color: #00B38A !important;
}
table#Footer td{
border:none;
padding:0;
}
#footer{
margin-bottom: 5px;
}
#main_head #SiteTitle{
height:70px;
background-color: #F8F8F8;
}
#Header #SiteTitle{
height:70px;
background-color: #F8F8F8;
padding-bottom: 0;
}
#Header #BlogTitle{
padding:0;
top:10px;
}
#main_body {
background: #fff;
}
#BodyTable tbody tr:nth-child(2){
background: transparent;
padding:0;
margin:0;
}
td#Body{
border:none;
}
#content_area{
border:none;
}
`;
// 左侧菜单
cnblogsAdminCss += `
/* 左侧随笔 */
#main_body #left_container{
margin-top: 0;
border: none;
}
/* 左侧文章 */
#BodyTable #LeftNavHeader{
margin-top: 0;
padding:0;
}
div.LeftNavHeader{
margin-top: 0;
}
#main_body #left_container #left_nav h2 {
color: #fff;
height: 36px;
font-size: 18px;
font-weight: bold;
line-height: 32px;
background: #00b38a;
margin:0;
padding:0;
border-top: 1px solid #00b38a;
border-right: 1px solid #00b38a;
}
#main_body #left_container #sidebar_categories h2{
color: #fff;
height: 36px;
font-size: 18px;
font-weight: bold;
line-height: 32px;
background: #00b38a;
border: 1px solid #00b38a;
margin:0;
padding:0;
}
#BodyTable #LeftNavHeader{
color: #fff;
height: 36px;
font-size: 18px;
font-weight: bold;
line-height: 32px;
background: #00b38a;
border: 1px solid #00b38a;
}
#BodyTable #CategoriesHeader{
color: #fff;
height: 36px;
font-size: 18px;
font-weight: bold;
line-height: 32px;
background: #00b38a;
border: 1px solid #00b38a;
padding: 0;
}
#BodyTable .left_nav{
padding:0;
}
#BodyTable .left_nav ul{
margin: 0;
background-color: rgb(50, 65, 87);
}
#BodyTable #LinksActions{
margin: 0;
}
#main_body #left_container #left_nav ul{
background-color: rgb(50, 65, 87);
}
#main_body #left_container #sidebar_categories ul{
background-color: rgb(50, 65, 87);
}
#main_body #sub_nav{
display: none;
}
#BodyTable #SubNav{
display: none;
}
#BodyTable ul#TopNav a{
background-color: #fff;
border: none;
font-size: 20px;
padding: 5px 5px 15px 0;
font-weight: bold;
text-decoration: none;
color: #555 !important;
height: 36px;
}
#BodyTable ul#TopNav a:hover{
color: #00B38A !important;
}
ul#TopNav{
height:36px;
}
ul#TopNav li{
padding: 0 2px 0 0;
}
#tab_nav{
border: none;
}
#tab_nav ul{
height:36px;
border: none;
}
#tab_nav li a.current_nav:link, #tab_nav li a.current_nav:visited, #tab_nav li a.current_nav:active{
background-color: #fff;
border: none;
border-bottom: 2px solid #0dca9f;
font-size: 20px;
padding: 5px 5px 1px 5px;
font-weight: bold;
text-decoration: none;
color: #555 !important;
}
#tab_nav li a:link, #tab_nav li a:visited, #tab_nav li a:active{
background-color: #fff;
border: none;
font-size: 20px;
padding: 5px 5px 1px 5px;
font-weight: bold;
text-decoration: none;
color: #555 !important;
}
#tab_nav li a.current_nav:hover{
color: #00B38A !important;
}
#tab_nav li a:hover{
color: #00B38A !important;
}
#main_body #left_container #left_nav ul{
padding: 0;
}
#main_body #left_container #sidebar_categories ul{
padding: 0;
}
#BodyTable #LinksActions{
padding: 0;
}
#main_body #left_nav ul li{
padding: 10px 20px;
}
#main_body #sidebar_categories ul li{
padding: 10px 20px;
}
#BodyTable ul#LinksActions li{
padding: 10px 20px;
height: auto;
}
#BodyTable ul#LinksCategories li{
padding: 10px 20px;
}
#main_body #left_nav ul li a{
color: #fff !important;
text-decoration: none;
font-size: 16px;
}
#main_body #sidebar_categories ul li a{
color: #fff !important;
text-decoration: none;
font-size: 16px;
}
#BodyTable ul#LinksActions li a{
color: #fff !important;
text-decoration: none;
font-size: 16px;
}
#BodyTable ul#LinksCategories li a{
color: #fff !important;
text-decoration: none;
font-size: 16px;
}
#main_body #left_nav ul li:hover{
background-color: rgb(40, 52, 70);
}
#BodyTable ul#LinksActions li:hover{
background-color: rgb(40, 52, 70);
}
#BodyTable ul#LinksCategories li:hover{
background-color: rgb(40, 52, 70);
}
#main_body #sidebar_categories ul li:hover{
background-color: rgb(40, 52, 70);
}
#main_wrap{
position:absolute;
margin-left:190px;
max-width:1150px;
}
#main_container{
margin: 0;
}
#left_container{
width: 187px;
}
#content_area{
padding: 0;
}
td.NavLeftCell{
width:200px;
}
#Main {
padding: 0 5px;
}
#content_area #post_list{
margin: 15px 0 0 3px !important;
}
`;
// 随笔列表
cnblogsAdminCss +=`
.table{
font-size:16px;
}
#post_list .post-title{
width: 50%;
}
#post_list td {
padding: 10px;
}
#post_list table th {
font-weight: bold;
color: inherit;
border: 1px solid #dee2e6 !important;
width: 10%;
text-align: center;
padding: 10px;
}
#post_list table{
border: none;
}
#Results_Contents table{
border: none;
}
#Results_Contents table td {
padding: 10px;
font-size: 16px;
}
#Results_Contents table th {
font-weight: bold;
color: inherit;
border: 1px solid #dee2e6 !important;
width: 10%;
text-align: center;
padding: 10px;
font-size: 16px;
}
#Editor_Results_Contents table{
border: none;
}
#Editor_Results_Contents table td {
padding: 10px;
font-size: 16px;
}
#Editor_Results_Contents table td a{
padding: 10px;
font-size: 16px;
}
#Editor_Results_Contents table th{
border: 1px solid #dee2e6 !important;
padding: 10px;
font-size: 16px;
text-align: center;
font-weight: bold;
}
#Editor_Results_Contents table th:nth-child(1) {
width: 60%;
}
div#Main div.Edit p.Label, label{
font-size: 14px;
}
#Edit_ddlSkin{
font-size: 16px;
}
#Edit_Contents{
font-size: 16px;
}
`;
// 添加新随笔
cnblogsAdminCss +=`
div.CollapsibleTitle,div.CollapsibleHeader {
color: #fff;
background: #00b38a;
border-bottom: 1px dashed #00b38a;
border-top: 1px solid #00b38a;
font-size: 16px;
}
`;
//与元数据块中的@grant值相对应,功能是生成一个style样式
GM_addStyle(cnblogsAdminCss);
// make site title
makeSiteTitle();
// make left op
makeLeftOp();
// make table
makeTable();
// 页面标题
function makeSiteTitle(){
$("#SiteTitle").html("<h2><a href='https://i.cnblogs.com/'>博客园文章管理后台</a></h2>");
$("#blog_title").html("<h3><a target='blank' href='https://www.cnblogs.com/"+config.author+"'>"+config.blogName+"</a></h2>");
$("#BlogTitle").html("<h3><a target='blank' href='https://www.cnblogs.com/"+config.author+"'>"+config.blogName+"</a></h2>");
}
function makeLeftOp(){
if(typeof $("#CategoriesHeader").html() != "undefined" && $("#CategoriesHeader").html().trim() == ""){
$("#CategoriesHeader").css("background","#fff");
$("#CategoriesHeader").css("border","none");
}
$("#SubNav").remove();
var href=window.location.href;
if(href.indexOf("EditPosts")>=0){
$("#TabPosts").css("border-bottom","2px solid #0dca9f");
$("#edit_container").css("font-size","18px");
$("#edit_container b").css("font-size","18px");
$("#edit_container div").css("font-size","18px");
$("#edit_container label").css("font-size","18px");
$("#edit_container input[type='text']").addClass("form-control").css("width","100%").css("border","1px solid #ced4da");
$("#edit_container textarea").addClass("form-control").css("width","100%");
$("#edit_container .Button").removeClass("Button").removeClass("Button").addClass("btn");
$("#Editor_Edit_lkbPost").addClass("btn-primary");
$("#Editor_Edit_lkbDraft").addClass("btn-default").css("border","1px solid #ced4da");
$("#Editor_Edit_lkbCancel").addClass("btn-danger");
}else if(href.indexOf("EditArticles")>=0){
$("#TabArticles").css("border-bottom","2px solid #0dca9f");
}else if(href.indexOf("EditDiary")>=0){
$("#TabDiary").css("border-bottom","2px solid #0dca9f");
$("#Editor_Results_Contents #Editor_Results_NoMessagesLabel").addClass("form-control").css("width","99%").css("margin-top","10px");
// 移除分页
$("#Editor_Results_Contents .Pager").empty();
}else if(href.indexOf("Feedback")>=0){
$("#TabFeedback").css("border-bottom","2px solid #0dca9f");
$("#Results_headerTitle").html("评论");
}else if(href.indexOf("EditLinks")>=0){
$("#TabLinks").css("border-bottom","2px solid #0dca9f");
}else if(href.indexOf("EditGalleries")>=0){
$("#TabGalleries").css("border-bottom","2px solid #0dca9f");
$("#Results_Add_Contents .Block").css("font-size","18px");
$("#Results_Add_txbNewTitle").addClass("form-control").css("width","100%").css("border","1px solid #ced4da");
$("#Results_Add_txbNewDescription").addClass("form-control").css("width","100%");
$("#Results_Add_lkbPost").val("保存").removeClass("form-control").removeClass("Button").addClass("btn btn-primary");
var filteredHtml = $("#Results_Add_txbNewTitle").parent().html().replace("Visible","可见").replace("1000 characters including HTML","最多包含html在内的1000个字符");
$("#Results_Add_txbNewTitle").parent().html(filteredHtml);
}else if(href.indexOf("Files")>=0){
$("#TabFiles").css("border-bottom","2px solid #0dca9f");
var fas = $("#Results_Contents table td a");
fas.each(function(i,n){
console.log(n);
var txt = $(n).html();
if(txt=="Download"){
$(n).html("下载");
}else if(txt=="Delete"){
$(n).html("删除");
}
});
}else if(href.indexOf("Configure")>=0){
$("#TabConfigure").css("border-bottom","2px solid #0dca9f");
$("#Edit_Contents .Block").addClass("form-control");
$("#Edit_Contents input,select,textarea").addClass("form-control");
$("#Edit_ckbAllowServiceAccess").removeClass("form-control").parent().addClass("form-control");
$("#Edit_lkbPost").val("保存").removeClass("form-control").removeClass("Button").addClass("btn btn-primary");
$("#Edit_Contents textarea").css("width","100%").css("height","320px");
$("#Edit_txbTitle").css("width","100%").css("border","1px solid #ced4da");
$("#Edit_Contents label").css("border","none").css("background","#F2F5F4").css("font-size","18px");
$("#Edit_ckbAllowServiceAccess").parent().css("padding-bottom","50px");
$("#Edit_EditorBody").parent().css("width","100%");
}else if(href.indexOf("Preferences")>=0){
$("#TabPreferences").css("border-bottom","2px solid #0dca9f");
$("#Edit_Contents p").each(function(i,n){
if($(n).html()!=""){
$(n).addClass("form-control");
}
});
var cp =$("#Edit_chkIsArticleOnHome").parent();
$(cp).addClass("form-control").css("padding",0);
$(cp).find("label").eq(0).css("padding-left","10px");
var dis = $("#Edit_chkDisableSubscibeNotify").parent();
$(dis).css("margin-top","15px");
var cm = $("#Edit_EnableComments").parent();
$(cm).css("margin-top","8px");
$("#Edit_rblEditor tr td").addClass("form-control").css("margin-top","5px").css("margin-bottom","10px");
$("#Edit_Contents fieldset").css("width","100%");
$("#Edit_cklSkinControl").addClass("table table-striped table-condensed table-hover").css("margin-top","5px");
$("#Edit_cklSkinControl tr td").css("width","3%")
$("#Edit_cklSkinControl tr td:nth-child(5)").css("width","7%");
$("#Edit_cklSkinControl tr td:nth-child(6)").css("width","7%");
$("#Edit_cklSkinControl tr td label").css("font-size","14px");
$("#Edit_lkbUpdate").val("保存").removeClass("Button").addClass("btn btn-primary");
$("#Edit_lkbCancel").val("取消").removeClass("Button").addClass("btn btn-danger").css("margin-left","10px");;
}else{
$("#TabPosts").css("border-bottom","2px solid #0dca9f");
}
}
function makeTable(){
$("#post_list table").addClass("table table-bordered table-striped table-condensed table-hover");
$("#post_list table .post-title a").attr("target","_blank");
$("#AddFiles_myFile").addClass("form-control").css("height","auto");
$("#AddFiles_Contents div").css("color","#00b38a");
$("#AddFiles_lbkAddFile").removeClass("Button").addClass("btn btn-primary");
$("#Results_Contents table").addClass("table table-bordered table-striped table-condensed table-hover").css("margin-top","10px");
$("#Editor_Results_Contents table").addClass("table table-bordered table-striped table-condensed table-hover").css("margin-top","10px");
}
})();