gab-social/docs/example-share-button.html
2021-01-20 01:10:00 +00:00

59 lines
1.8 KiB
HTML

<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>