-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
88 lines (76 loc) · 3.53 KB
/
index.html
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
<!DOCTYPE html>
<head>
<meta name="title" content="Markdown external link opener">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Allow external links in your markdown be opened on a different tab">
<meta name="keywords" content="markdown, links, external links">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="English">
<meta name="revisit-after" content="2 days">
<meta name="author" content="Eddymens">
<title>Markdown external link opener</title>
</head>
<style>
#external-link {
color: #494747;
text-decoration: none;
font-style: italic;
font-family: Tahoma, sans-serif;
}
#main-pan {
text-align: center;
padding: 70px 0;
display: none;
}
#link-display {
font-size: 20px;
}
body {
font-size: 40px;
background-color: #cecece;
}
</style>
<body>
<div id="main-pan">
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd">
<path
d="M14.851 11.923c-.179-.641-.521-1.246-1.025-1.749-1.562-1.562-4.095-1.563-5.657 0l-4.998 4.998c-1.562 1.563-1.563 4.095 0 5.657 1.562 1.563 4.096 1.561 5.656 0l3.842-3.841.333.009c.404 0 .802-.04 1.189-.117l-4.657 4.656c-.975.976-2.255 1.464-3.535 1.464-1.28 0-2.56-.488-3.535-1.464-1.952-1.951-1.952-5.12 0-7.071l4.998-4.998c.975-.976 2.256-1.464 3.536-1.464 1.279 0 2.56.488 3.535 1.464.493.493.861 1.063 1.105 1.672l-.787.784zm-5.703.147c.178.643.521 1.25 1.026 1.756 1.562 1.563 4.096 1.561 5.656 0l4.999-4.998c1.563-1.562 1.563-4.095 0-5.657-1.562-1.562-4.095-1.563-5.657 0l-3.841 3.841-.333-.009c-.404 0-.802.04-1.189.117l4.656-4.656c.975-.976 2.256-1.464 3.536-1.464 1.279 0 2.56.488 3.535 1.464 1.951 1.951 1.951 5.119 0 7.071l-4.999 4.998c-.975.976-2.255 1.464-3.535 1.464-1.28 0-2.56-.488-3.535-1.464-.494-.495-.863-1.067-1.107-1.678l.788-.785z" />
</svg>
<a onclick='history.back()' target='_blank' href="#" id='external-link'><span id="altText">Click here to visit
the page...</span></a>
<div>
<a id="link-display" onclick='history.back()' target="_blank" href="#">Link here</a>
</div>
</div>
</body>
<script>
// Get query params
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});
//check if link is provided
if(!params.to) {
if(document.referrer.length) {
history.back();
}
window.location.href = 'https://github.com/EDDYMENS/markdown-external-link-opener/blob/main/README.md';
}
//make link absolute
var link = (params.to.startsWith('http'))? params.to : '//'+params.to;
// open defined link in a new tab
window.open(link, '_blank');
// Show user external link incase of popup block
let browser_active = ((typeof document.hasFocus != 'undefined' ? document.hasFocus() : 1) ? 1 : 0);
if (browser_active) {
mainPan = document.getElementById('main-pan');
mainPan.style.display = 'block';
externalAnchorLink = document.getElementById('external-link');
externalLinkDisplay = document.getElementById('link-display');
externalAnchorLink.href = link;
externalLinkDisplay.href = link;
externalLinkDisplay.text = link;
} else {
history.back();
}
</script>
</html>