-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
56 lines (49 loc) · 1.87 KB
/
index.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
;(function(window) {
window.DocsifyCodefund = {
scriptEl: null,
create: function(codefundId) {
return function(hook, vm) {
hook.ready(function() {
window.DocsifyCodefund.injectCodeFundStyle();
})
hook.doneEach(function () {
window.DocsifyCodefund.injectCodeFundScript(codefundId);
window.DocsifyCodefund.injectCodeFundContainer();
})
}
},
injectCodeFundContainer: function() {
if (document.getElementById("codefund") === null) {
var nav = document.getElementsByClassName('sidebar-nav');
var codefundContainer = document.createElement('div');
codefundContainer.id = 'codefund';
nav[0].insertBefore(codefundContainer, nav[0].firstChild);
}
if (document.getElementsByClassName('cf-wrapper').length === 0) {
window._codefund && window._codefund.serve();
}
},
injectCodeFundScript: function(codefundId) {
if (window.DocsifyCodefund.scriptEl) {
window.DocsifyCodefund.scriptEl.remove()
}
var script = document.createElement('script')
script.src = "https://codefund.io/properties/" + codefundId + "/funder.js?template=docsify"
script.async = "async"
document.body.appendChild(script)
window.DocsifyCodefund.scriptEl = script
},
injectCodeFundStyle: function() {
var style = document.createElement('style');
window.DocsifyCodefund.injectCodeFundContainer();
var css = '#cf span.cf-wrapper { background-color: transparent!important } #cf a.cf-text { color: #444!important; font-weight: 400!important; font-size: 10px!important }';
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
document.head.appendChild(style);
}
}
})(window)