Add example share button to this public repo

This commit is contained in:
admin 2021-01-20 00:51:00 +00:00
parent 406cbbe747
commit 12353c7c9b
1 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,58 @@
<html>
<head>
<!-- <title>Rob's Testing Page</title> -->
<!-- <meta name="description" content="This is Rob's demo and testing page."> -->
</head>
<body>
<style type="text/css">
a.gab-share-btn {
display: inline-block;
padding: 8px 12px;
background: #00d178;
color: #ffffff;
border: solid 1px transparent;
border-radius: 8px;
font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
text-decoration: none;
font-weight: bold;
font-size: inherit;
cursor: pointer;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
a.gab-share-btn:hover {
border-color: black;
}
a.gab-share-btn:active {
border-color: #e8e8e8;
background: #01854b;
box-shadow: 0 0 4px rgba(0,0,0,0.2) inset;
}
</style>
<a
id="gab-share-btn"
class="gab-share-btn"
title="Share to Gab"
target="_blank"
>Share to Gab</a>
<script>
(async function ( ) {
const button = document.getElementById('gab-share-btn');
const title = document.querySelector('head title');
if (!title) { button.setAttribute('hidden', true); }
let description = document.querySelector('head meta[name="description"]');
let text = title.textContent + '\n';
if (description) { text += description.getAttribute('content') + '\n\n'; }
button.setAttribute('href', `https://gab.com/compose?url=${encodeURIComponent(window.location.href)}&text=${encodeURIComponent(text)}`);
})();
</script>
</body>
</html>