-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocCleaner.user.js
941 lines (926 loc) · 31 KB
/
DocCleaner.user.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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
// ==UserScript==
// @name DocCleaner
// @namespace Feast.Script.DocCleaner
// @version 1.0
// @description 🍊各种乱七八糟的网页的人性化调整,秦始皇看了大为称赞🍊
// @author 终宴
// @match https://blog.csdn.net/*
// @match https://link.csdn.net/*
// @match https://c.pc.qq.com/*
// @match https://cloud.tencent.com/*
// @match https://stackoverflow.com/*
// @match https://stackoverflow.org.cn/*
// @match https://www.jianshu.com/*
// @match https://www.codenong.com/*
// @match https://wenku.baidu.com/*
// @match https://zhuanlan.zhihu.com/*
// @match https://link.zhihu.com/*
// @match https://www.zhihu.com/*
// @match https://www.aliyunjc.net/*
// @match https://www.xuexila.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=stackoverflow.com
// @require https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js
// @grant none
// ==/UserScript==
(function () {
"use strict";
//全局函数
const Global = {
/**
* 由to接管from自身
* @param {Object} from 被接管的元素
* @param {Object} to 接管的元素
*/
takeover: function (from, to) {
from.parentElement?.removeChild(from);
to.appendChild(from);
},
/**
* 由to接管from的子元素
* @param {Object} from 被接管的容器
* @param {Object} to 接管的元素
*/
grab: function (from, to) {
let childs = [];
from.childNodes.forEach((x) => childs.push(x));
childs.forEach((x) => {
from.removeChild(x);
to.appendChild(x);
});
},
/**
* 加载插件
* @param {String} src 插件url
* @param {{Name:String,onPlugin:Function}} option 插件选项
*/
script: function (src, option) {
let script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.src = src;
document.head.appendChild(script);
if (option) {
if (option.Name && !this.Plugins[option.Name]) {
this.Plugins[option.Name] = {};
Startup.onPlugin((win) => {
let plugin = (this.Plugins[option.Name] =
win[option.Name]);
if (option.onPlugin) {
option.onPlugin(plugin);
}
});
}
}
},
css: function (src) {
let link = document.createElement("link");
link.setAttribute("rel", "stylesheet");
link.href = src;
document.head.appendChild(link);
},
addCSP: function () {
let meta = document.createElement("meta");
meta.setAttribute(
"content",
"script-src cdn.jsdelivr.net; object-src 'self'; style-src 'self' 'unsafe-inline'; media-src *"
);
meta.setAttribute("http-equiv", "Content-Security-Policy");
document.head.appendChild(meta);
},
loadVue: function (handler) {
//https://cdn.jsdelivr.net/npm/vue@next 用以获取最新的js
this.script(
"https://cdn.jsdelivr.net/npm/vue@3.2.36/dist/vue.global.min.js",
{ Name: "Vue", onPlugin: handler }
);
},
loadElement: function (handler) {
//https://unpkg.com/element-plus 用以获取最新的js
this.script(
"https://unpkg.com/element-plus@2.2.22/dist/index.full.min.js",
{ Name: "ElementPlus", onPlugin: handler }
);
this.css("https://unpkg.com/element-plus/dist/index.css");
},
loadSignalR: function (handler) {
this.script(
"https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/7.0.2/signalr.min.js",
{ Name: "signalR", onPlugin: handler }
);
},
inject: function (Element) {
let childs = [];
document.body.childNodes.forEach((x) => childs.push(x));
childs.forEach((x) => document.body.removeChild(x));
document.body.appendChild(Element);
childs.forEach((x) => document.body.appendChild(x));
},
insertCss: function (rules, doc) {
if (!doc) {
doc = document;
}
new Promise((res, rej) => {
for (let i = 0; i < doc.styleSheets.length; i++) {
rules.forEach((rule) => {
try {
if (typeof rule == "string")
doc.styleSheets[i].insertRule(rule, 0);
} catch (error) { }
});
}
res();
});
},
export: function (win) {
if (!win) {
win = window;
}
Object.keys(this).forEach((key) => {
win[key] = this[key];
});
},
/**
* 合成
* @param {object} self
* @param {object} from
*/
merge(self, from) {
if (!from) return;
Object.keys(from).forEach((key) => {
var tmp = from[key];
if (!self[key]) {
self[key] = tmp;
} else if (typeof self[key] == typeof tmp) {
if (tmp.forEach) {
tmp.forEach((v) => {
if (self[key].push) {
self[key].push(v);
}
});
} else if (typeof self[key] == "object") {
this.merge(self[key], tmp);
} else {
self[key] = tmp;
}
}
});
},
Plugins: {},
};
Object.freeze(Global);
class UIElement {
constructor(tag, id, hidden) {
let ele =
(this.Container =
this.Element =
document.createElement(tag));
if (id) {
ele.id = id;
}
if (hidden) {
ele.style.display = "none";
}
}
Element = null;
Container = null;
show = function () {
this.Element.style.display = "";
};
hide = function () {
this.Element.style.display = "none";
};
add = function (Element) {
this.Element.appendChild(Element);
};
remove = function (Element) {
this.Element.removeChild(Element);
};
takeover = function (target) {
Global.takeover(target, this.Container);
};
grab = function (target) {
Global.grab(target, this.Container);
};
}
class Setter {
constructor() {
this.innerText = null;
this.attributes = {};
this.style = null;
}
/**
* 拷贝自
* @param {Setter} other
*/
from(other) {
Global.merge(this, other);
}
}
//启动项 Startup.on( url, BeforeEvent(context) ,StartEvent(context,window,plugins) , context = null )
const Startup = {
PluginEvents: [],
PreloadEvents: [],
BoostConfigs: {},
AfterloadEvents: [],
/**
* 注册启动事件
* @param {String} url 启动地址
* @param {Function} before 预加载事件
* @param {Function} start 主事件
* @param {Object|null} context 预置或默认生成的上下文
* @returns void
*/
on: function (url, before, start, context) {
if (typeof url != "string") {
return;
}
if (typeof before != "function") {
before = () => { };
}
if (typeof start != "function") {
start = () => { };
}
if (!context) {
context = {};
}
this.BoostConfigs[url] = {
Context: context,
OnBefore: before,
OnStart: start,
};
},
/**
* 注册加载完成的事件
* @param {Function} loadEvent
*/
onLoad: function (loadEvent) {
this.PreloadEvents.push(loadEvent);
},
/**
* 插件加载完成的事件
* @param {Function} loadEvent
*/
onPlugin: function (loadEvent) {
this.PluginEvents.push(loadEvent);
},
/**
* 加载完成后的事件
* @param {Function} loadEvent
*/
afterLoad: function (loadEvent) {
this.AfterloadEvents.push(loadEvent);
},
};
Object.freeze(Startup);
//控件模板
const Template = {
/**
* 创建一个 ElementPlus 的 el-affix
* @param {String} id 控件的id
* @param {Number} offset 控件的垂直偏移
* @param {String} viewModel 绑定的vm(data:{...})
* @param {Function} modify 后处理
* @param {Setter} buttonSetter 按钮设置
* @returns 元素
*/
Affix: function (id, offset, viewModel, modify, buttonSetter) {
let defaultSetter = {
innerText: "展开",
attributes: {
plain: "",
type: "primary",
"v-on:click": `()=> ${viewModel} = true`,
":style": "{ boxShadow:'var(--el-box-shadow-dark)' }",
},
style: "padding:20px",
};
Global.merge(defaultSetter, buttonSetter);
let ret = new UIElement("el-affix", id).Element;
ret.setAttribute(":offset", offset);
let button = new UIElement("el-button").Element;
Object.keys(defaultSetter).forEach((k) => {
if (k == "attributes") {
Object.keys(defaultSetter.attributes).forEach((key) => {
button.setAttribute(key, defaultSetter.attributes[key]);
});
} else {
button[k] = defaultSetter[k];
}
});
ret.appendChild(button);
if (modify) {
Startup.afterLoad((win, plugins) => {
modify(win.document.getElementById(id).childNodes[0]);
});
}
return ret;
},
/**
* 创建一个 ElementPlus 的 el-drawer
* @param {String} id 控件的id
* @param {Number} width 控件的宽度
* @param {String} direction 控件展开方向
* @param {String} viewModel 绑定的vm
* @param {String} openEventName el-drawer的加载事件名
* @returns 元素
*/
Drawer: function (id, direction, viewModel, openEventName) {
let inner = new UIElement("div");
inner.Element.id = id;
let ret = new UIElement("el-drawer").Element;
ret.setAttribute("size", "auto");
ret.setAttribute(":with-header", false);
ret.setAttribute("direction", direction);
ret.setAttribute("v-model", viewModel);
ret.setAttribute("v-on:open", "() => " + openEventName + "()");
ret.appendChild(inner.Element);
return ret;
},
/**
* 快速创建一个接管容器
* @param {String} tag 容器标签
* @param {Object} victim 被接管的元素
* @param {String} mode 接管模式(takeover/grab)
* @param {Function} afterCreate 后处理
* @returns {UIElement} 元素
*/
Wrapper: function (tag, victim, mode, afterCreate) {
let ret = new UIElement(tag);
ret.Element.style.width = victim.clientWidth + "px";
switch (mode) {
case "takeover":
ret.takeover(victim);
break;
case "grab":
ret.grab(victim);
break;
}
if (afterCreate) {
afterCreate(ret.Element);
}
return ret.Element;
},
/**
* 从配置的App中创建app
* @param {Object} configure Vue配置的App
* @param {Object} plugins Global.plugins
* @param {Object} mount 挂载在界面上的元素
* @param {Function} after 后处理
* @returns 创建完的app
*/
CreateApp: function (configure, plugins, mount, after) {
if (!plugins.Vue) return;
let ret = plugins.Vue.createApp(configure);
if (plugins.ElementPlus) {
ret.use(plugins.ElementPlus);
ret.$message = plugins.ElementPlus.ElMessage;
}
if (mount) {
ret.mount(mount);
}
if (after) {
after(ret);
}
return ret;
},
};
const LOG = (l) => {
console.log(l);
};
const href = window.location.host;
//TODO:在此开始编写
//CSDN
Startup.on(
"blog.csdn.net",
(context) => {
let visual = (context.Visual = new UIElement(
"div",
"Feast-app",
true
));
Global.inject(visual.Element);
Global.loadVue();
Global.loadElement();
context.setClickable();
window.$(window).unbind();
let main = document.getElementById("mainBox");
let aside = main.childNodes[5];
context.Aside = Template.Wrapper("aside", aside, "grab");
main.childNodes[3].style.width = "100%";
let affix = Template.Affix("affix", 120, "draw", (a) => {
a.style.left = "30px";
});
let drawer = Template.Drawer(
"drawerContainer",
"ltr",
"draw",
"onOpen"
);
visual.add(affix);
visual.add(drawer);
},
(context, _, plugins) => {
let visual = context.Visual;
const App = {
created(){
context.Aside.onmouseleave = () => {
this.draw = false;
}
},
data() {
return {
draw: false,
onOpen: function () {
Global.takeover(
context.Aside,
document.getElementById("drawerContainer")
);
},
};
},
};
const app = Template.CreateApp(App, plugins, visual.Element, () => {
visual.show();
});
context.setClickable(() => {
app.$message.success("复制成功");
});
if (context.Aside) {
app.$message.success("左边栏收起了噢");
} else {
app.$message.warning("没有找到捏");
}
},
{
setClickable: (Alert) => {
let hs = document.getElementsByClassName("hljs-button signin");
for (let i = 0; i < hs.length; i++) {
hs.item(i).onclick = () => {
window.hljs.copyCode(event);
if (Alert) {
Alert();
}
};
hs.item(i).setAttribute("data-title", "尽情的复制吧");
}
document.querySelectorAll("code").forEach((x) => {
x.style.userSelect = "text";
});
},
}
);
//CSDN外链
Startup.on("link.csdn.net", (_) => {
let link = new URL(window.location.href).searchParams.get("target");
if (link) {
window.location.href = link;
}
});
//qq外链
Startup.on(
"c.pc.qq.com",
(_) => {
let link = new URL(window.location.href).searchParams.get("pfurl");
if (link) {
window.location.href = link;
}
},
null
);
//腾讯云
Startup.on(
"cloud.tencent.com",
(context) => {
let visual = (context.Visual = new UIElement(
"div",
"Feast-app",
true
));
Global.inject(visual.Element);
Global.loadVue();
Global.loadElement();
let rightSide = document.getElementsByClassName("layout-side")[0];
let affix = Template.Affix("right-affix", 120, "RightDraw", (a) => {
a.style.right = "100px";
});
let drawer = Template.Drawer(
"rightDrawerContainer",
"rtl",
"RightDraw",
"onRightOpen"
);
context.RightAside = Template.Wrapper(
"aside",
rightSide,
"takeover"
);
visual.add(affix);
visual.add(drawer);
},
(context, _, plugins) => {
let visual = context.Visual;
const App = {
created(){
context.RightAside.onmouseleave = () => {
this.RightDraw = false;
}
},
data() {
return {
RightDraw: false,
onRightOpen: function () {
Global.takeover(
context.RightAside,
document.getElementById("rightDrawerContainer")
);
},
};
},
};
let app = Template.CreateApp(App, plugins, visual.Element, () => {
visual.show();
});
if (context.RightAside) {
app.$message.success("右侧栏收起");
} else {
app.$message.warning("没有找到捏");
}
}
);
//StackOverflow
let StackOverFlowBefore = (context) => {
let visual = (context.Visual = new UIElement("div", "Feast-app", true));
Global.inject(visual.Element);
Global.loadVue();
Global.loadElement();
let rightSide = document.getElementById("sidebar");
document.getElementById("mainbar").style.width =
"calc(100% - let(--su-static24))";
let affix = Template.Affix("right-affix", 120, "RightDraw", (a) => {
a.style.right = "100px";
});
let drawer = Template.Drawer(
"rightDrawerContainer",
"rtl",
"RightDraw",
"onRightOpen"
);
context.RightAside = Template.Wrapper("aside", rightSide, "takeover");
visual.add(affix);
visual.add(drawer);
};
let StackOverFlowStart = (context, _, plugins) => {
let visual = context.Visual;
const App = {
created(){
context.RightAside.onmouseleave = () => {
this.RightDraw = false;
}
},
data() {
return {
RightDraw: false,
onRightOpen: function () {
let inner = document.getElementById(
"rightDrawerContainer"
);
let drawer = inner.parentElement;
drawer.style.marginTop = "50px";
drawer.style.marginBottom = "10px";
Global.takeover(context.RightAside, inner);
},
};
},
};
Template.CreateApp(App, plugins, visual.Element, () => {
visual.show();
});
};
Startup.on("stackoverflow.com", StackOverFlowBefore, StackOverFlowStart);
Startup.on("stackoverflow.org.cn", StackOverFlowBefore, StackOverFlowStart);
//简书
Startup.on(
"www.jianshu.com",
(context) => {
Global.loadVue();
Global.loadElement();
let visual = (context.Visual = new UIElement(
"div",
"Feast-app",
true
));
Global.inject(visual.Element);
let rightSide = document.querySelector("aside");
let affix = Template.Affix("right-affix", 120, "RightDraw", (a) => {
a.style.right = "100px";
});
let drawer = Template.Drawer(
"rightDrawerContainer",
"rtl",
"RightDraw",
"onRightOpen"
);
context.RightAside = Template.Wrapper(
"aside",
rightSide,
"takeover"
);
document.querySelector("[role=main]").childNodes[0].style.width =
"100%";
visual.add(affix);
visual.add(drawer);
},
(context, _, plugins) => {
let visual = context.Visual;
const App = {
created(){
context.RightAside.onmouseleave = () => {
this.RightDraw = false;
}
},
data() {
return {
RightDraw: false,
onRightOpen: function () {
let inner = document.getElementById(
"rightDrawerContainer"
);
Global.takeover(context.RightAside, inner);
},
};
},
};
Template.CreateApp(App, plugins, visual.Element, () => {
visual.show();
});
}
);
//码农家园
Startup.on("www.codenong.com", (_) => {
document.getElementById("primary").style.width = "100%";
});
//百度文库
Startup.on(
"wenku.baidu.com",
(context) => {
let visual = (context.Visual = new UIElement(
"div",
"Feast-app",
true
));
Global.inject(visual.Element);
Global.loadVue();
Global.loadElement();
context.Aside = Template.Wrapper(
"aside",
document.getElementById("app-right"),
"takeover"
);
let main = document.getElementsByClassName("center-wrapper")[0];
main.style.width = "calc(100% - 280px)";
let affix = Template.Affix("right-affix", 120, "RightDraw", (a) => {
a.style.right = "90px";
});
let drawer = Template.Drawer(
"rightDrawerContainer",
"rtl",
"RightDraw",
"onRightOpen"
);
visual.add(affix);
visual.add(drawer);
},
(context, _, plugins) => {
let visual = context.Visual;
const App = {
created(){
context.Aside.onmouseleave = () => {
this.RightDraw = false;
}
},
data() {
return {
RightDraw: false,
onRightOpen: function () {
Global.takeover(
context.Aside,
document.getElementById("rightDrawerContainer")
);
},
};
},
methods: {},
};
const app = Template.CreateApp(App, plugins, visual.Element, () => {
visual.show();
});
if (context.Aside) {
app.$message.success("右侧栏收起");
} else {
app.$message.warning("没有找到捏");
}
}
);
let zhihuContext = {
closeSign: function () {
let interval = setInterval(() => {
let targ = document.getElementsByClassName("Modal-wrapper")[0];
if (!targ) return;
clearInterval(interval);
document.getElementsByClassName("Modal-closeButton")[0].click();
}, 10);
},
closeBottom: function () {
let interval = setInterval(() => {
let targ = document.getElementsByClassName("css-1izy64v")[0];
if (!targ) return;
clearInterval(interval);
targ.parentElement.removeChild(targ);
}, 10);
},
};
//知乎
Startup.on(
"www.zhihu.com",
(context) => {
let visual = (context.Visual = new UIElement(
"div",
"Feast-app",
true
));
Global.inject(visual.Element);
Global.loadVue();
Global.loadElement();
context.closeSign();
context.closeBottom();
let aside = document.getElementsByClassName(
"Question-sideColumn"
)[0];
context.Aside = Template.Wrapper("aside", aside, "takeover");
let affix = Template.Affix("right-affix", 120, "RightDraw", (a) => {
a.style.right = "90px";
});
let drawer = Template.Drawer(
"rightDrawerContainer",
"rtl",
"RightDraw",
"onRightOpen"
);
visual.add(affix);
visual.add(drawer);
Global.insertCss([".Question-mainColumn { width:100% }"], document);
},
(context, _, plugins) => {
let visual = context.Visual;
const App = {
created(){
context.Aside.onmouseleave = () => {
this.RightDraw = false;
}
},
data() {
return {
RightDraw: false,
onRightOpen: function () {
Global.takeover(
context.Aside,
document.getElementById("rightDrawerContainer")
);
},
};
},
};
const app = Template.CreateApp(App, plugins, visual.Element, () => {
visual.show();
});
if (context.Aside) {
app.$message.success("右侧栏收起");
} else {
app.$message.warning("没有找到捏");
}
},
zhihuContext
);
//知乎专栏
Startup.on(
"zhuanlan.zhihu.com",
(context) => {
let width = "80%";
Global.insertCss([
".Post-SideActions { right:calc(50vw - 700px) }",
".css-78p1r9 { max-width:" + width + " }",
".Post-NormalMain .Post-Header { width:" + width + " }",
".Post-NormalMain>div, .Post-NormalSub>div { width:" +
width +
" }",
]);
context.closeSign();
context.closeBottom();
},
null,
zhihuContext
);
//知乎外链引导页面
Startup.on("link.zhihu.com", (_) => {
let link = new URL(window.location.href).searchParams.get("target");
if (link) {
window.location.href = link;
}
});
//免费资源网
Startup.on(
"www.aliyunjc.net",
(context) => {
Global.inject(context.Visual.Element);
Global.loadVue();
Global.loadElement();
let affix = Template.Affix(
"left-affix",
120,
"leftDraw",
(a) => {
a.style.left = "100px";
},
{
innerText: "复制",
attributes: {
"v-on:click": "copyAll",
},
}
);
context.Visual.add(affix);
},
(context, _, plugins) => {
document.body.oncopy = null;
Template.CreateApp(
context.App,
plugins,
context.Visual.Element,
() => {
context.Visual.show();
}
);
},
{
Visual: new UIElement("div", "Feast-app", true),
App: {
methods: {
copyAll() {
let text = "";
document.querySelectorAll("pre").forEach((x) => {
text += x.innerText;
});
navigator.clipboard
.writeText(text)
.then(() => {
this.$message.success("复制成功");
})
.catch((e) => {
this.$message.error("复制失败");
});
},
},
},
}
);
//学习啦
Startup.on(
"www.xuexila.com",
(context) => {
document.body.oncopy = null;
Global.inject(context.Visual.Element);
Global.loadVue();
Global.loadElement();
},
(context, __, plugins) => {
document.body.oncopy = null;
let app = Template.CreateApp(
context.App,
plugins,
context.Visual.Element,
() => {
context.Visual.show();
}
);
app.$message.success("清除 Ctrl+C 限制");
},
{
Visual: new UIElement("div", "Feast-app", true),
App: {},
}
);
//在以上区域编写
let config = Startup.BoostConfigs[href];
window.onload = () => {
Startup.PluginEvents.forEach((x) => {
x(window);
});
Startup.PreloadEvents.forEach((x) => {
x(window, Global.Plugins);
});
config.OnStart(config.Context, window, Global.Plugins);
Startup.AfterloadEvents.forEach((x) => {
x(window, Global.Plugins);
});
};
config.OnBefore(config.Context);
})();