-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinclude.js
More file actions
77 lines (73 loc) · 3.27 KB
/
include.js
File metadata and controls
77 lines (73 loc) · 3.27 KB
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
const head = document.head;
head.insertAdjacentHTML('beforeend', `
<link rel="stylesheet" href="/style.css">
<meta charset="utf-8">
<link rel="icon" href="/favicon.png">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" type="text/javascript"></script>
`);
//window.addEventListener('DOMContentLoaded',
(async function() {
var header = document.createElement("header");
header.innerHTML = `
<ul id=headerul>
<li class="head"> <a href="/" class="nav"><img src="/favicon.png" width="35px" height="35px" id="icon"></a> </li>
<li class="head"><a href="/" class="nav">Haru-ymth's Homepage</a></li>
<li class="head" id="sidebartoggle"> <a class="nav">その他</a> </li>
</ul>`;
var shadow=document.createElement("div");
shadow.id="_shadow";
document.body.after(shadow);
var footer=document.createElement("footer");
footer.id="infooter";
footer.innerHTML=`© 2022 yamaguchi03`;
document.body.after(footer)
var menu=document.createElement("iframe");
menu.id="menubar";
menu.src="/others";
menu.class="none";
var head=document.head;
head.after(header);
head.after(menu);
var html=document.getElementsByTagName("html")[0];
var googleAnalytics=document.createElement("div");
googleAnalytics.innerHTML=`<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-T5V03S2YS9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-T5V03S2YS9');
</script>`;/*var afterHead=document.head;
afterHead.after(googleAnalytics);*/
var sonota=document.getElementById("sidebartoggle");
sonota.addEventListener('click', function(){
if(document.getElementById("menubar").style.right=="0px"){
document.getElementById("_shadow").style.transitionDelay="0s,1s";
document.getElementById("menubar").style.right="-100vw";
document.getElementById("_shadow").style.opacity="0";
document.getElementById("_shadow").style.height="0";
}else{
document.getElementById("_shadow").style.transitionDelay="0s,0s";
document.getElementById("menubar").style.right="0px";
document.getElementById("_shadow").style.opacity="0.5";
document.getElementById("_shadow").style.height="100%";
}
});
var shad=document.getElementById("_shadow");
shad.addEventListener('click', function(){
document.getElementById("_shadow").style.transitionDelay="0s,1s";
document.getElementById("menubar").style.right="-100vw";
document.getElementById("_shadow").style.opacity="0";
document.getElementById("_shadow").style.height="0";
});
if(location.pathname=="/others"){return}
(async()=>{let visitorcount=await (await fetch("https://visitorcounts.haru-ymth.repl.co",{method:"POST",body:JSON.stringify({url:location.origin+location.pathname})})).text();
let visitorcount2=document.createElement("div");
visitorcount2.style="margin-top:50px;"
visitorcount2.innerText="このページが読み込まれた回数:"+visitorcount;
document.body.appendChild(visitorcount2)})();
})();
if(location.href.includes("#")){
newUrl=location.href.replace(/#/g,"");
replaceState("",document.title,newUrl);
}