This is all I have inside my Custom JavaScript. The Custom JavaScript is not as straightforward as the CSS. Some of the contents might not work on your site and you will need to debug them on the browser dev tools if they are not working.
Update: Some of them don’t seem to be working, or are not showing up on the site. Sorry, it’s been awhile since I’ve looked at the JS on my site. It all probably needs to be reviewed/updated.
// src: https://platform.twitter.com/widgets.js
/* Post Footer Links Section */
var showPreviousLinks = true;
var latestJournalEntryIndex = 80;
var latestMusicLogIndex = 38;
var latestWeeknotesIndex = 19;
var currentURL = window.location.href;
var isArchivePage = /\/archive$/i.test(currentURL);
var isSearchPage = /\/search$/i.test(currentURL);
var isCommentsPage = /\/comments$/i.test(currentURL);
var isSeriesAndTagsPage = /\/series-and-tags$/i.test(currentURL);
var isAboutPage = /\/about$/i.test(currentURL);
var isSubscribePage = /\/subscribe$/i.test(currentURL);
var isMusicLog = /\/music-log/i.test(currentURL);
var isWeeknotes = /\/weeknotes/i.test(currentURL);
// Insert footer links on posts, but not on the homepage or specific pages.
if (!isArchivePage && !isSearchPage && !isCommentsPage && !isSeriesAndTagsPage && !isAboutPage && !isSubscribePage) {
if (document.getElementById("post-body"))
{
var content = document.getElementById("post-body").innerHTML;
var disableFooterLinks = /nofooterlinks/i.test(content);
if (disableFooterLinks) {
var newContent = content.replace(/nofooterlinks/gi, "");
document.getElementById("post-body").innerHTML = newContent;
}
else {
var randomLinkText = '<a class="previousLink" title="Get Random post from this site" href="https://random-journal-post.glitch.me/get">Random↬</a>';
var backToTopLinkText = '<a class="previousLink" title="Back to top" href="#top">Top↑</a>';
/*var commentsLinkText = '<a class="previousLink" title="Questions, Comments or Concerns?" href="https://journal.dinobansigan.com/comments">Comments?</a>';*/
var previousLinkText = null;
var nextLinkText = null;
if (showPreviousLinks) {
var content = document.getElementById("post-body").innerHTML;
var isJournalEntry = /tag:JournalEntry/i.test(content);
var isGameLog = /tag:GameLog/i.test(content);
var isVideoGameScreenshots = /tag:GameScreenshots/i.test(content);
var isGameClips = /tag:GameClips/i.test(content);
var isBookReview = /tag:BookReview/i.test(content);
var element = document.querySelector('meta[property="og:url"]');
var content = element && element.getAttribute("content");
// Get post slug
var postSlug = content.split('/').pop();
var postIndex = postSlug.split('-').pop();
// Generate Previous link
if ((postIndex - 1) > 0 &&
(isJournalEntry || isGameLog || isMusicLog || isVideoGameScreenshots || isGameClips || isWeeknotes)) {
var previousLinkUrl = "https://journal.dinobansigan.com/";
var pad = '000'
var previousPostIndex = (pad + (postIndex - 1)).slice(-pad.length);
var postSlugSplit = postSlug.split('-');
var i;
for (i = 0; i < postSlugSplit.length; i++) {
if (i + 1 < postSlugSplit.length) {
previousLinkUrl = previousLinkUrl.concat(postSlugSplit[i] + "-");
} else {
previousLinkUrl = previousLinkUrl.concat(previousPostIndex);
}
}
previousLinkText = '<a class="previousLink" title="Get Previous entry in this series" href="';
previousLinkText = previousLinkText.concat(previousLinkUrl);
previousLinkText = previousLinkText.concat('">←Previous</a>');
}
else if (isJournalEntry || isBookReview) {
try {
previousLinkUrl = "https://journal.dinobansigan.com/" + document.getElementById("previousLinkSlug").innerHTML;
previousLinkText = '<a class="previousLink" title="Get Previous entry in this series" href="';
previousLinkText = previousLinkText.concat(previousLinkUrl);
previousLinkText = previousLinkText.concat('">←Previous</a>');
} catch (err) { }
}
// Generate Next link
var nextIndex = parseInt(postIndex) + 1;
if ((nextIndex <= latestJournalEntryIndex && isJournalEntry) ||
(nextIndex <= latestMusicLogIndex && isMusicLog) ||
(nextIndex <= latestWeeknotesIndex && isWeeknotes)) {
var nextLinkUrl = "https://journal.dinobansigan.com/";
var pad = '000'
var nextPostIndex = (pad + (parseInt(postIndex) + 1)).slice(-pad.length);
var postSlugSplit = postSlug.split('-');
var j;
for (j = 0; j < postSlugSplit.length; j++) {
if (j + 1 < postSlugSplit.length) {
nextLinkUrl = nextLinkUrl.concat(postSlugSplit[j] + "-");
} else {
nextLinkUrl = nextLinkUrl.concat(nextPostIndex);
}
}
nextLinkText = '<a class="previousLink" title="Get Next entry in this series" href="';
nextLinkText = nextLinkText.concat(nextLinkUrl);
nextLinkText = nextLinkText.concat('">Next→</a>');
} else if (isJournalEntry || isBookReview) {
try {
nextLinkUrl = "https://journal.dinobansigan.com/" + document.getElementById("nextLinkSlug").innerHTML;
nextLinkText = '<a class="previousLink" title="Get Next entry in this series" href="';
nextLinkText = nextLinkText.concat(nextLinkUrl);
nextLinkText = nextLinkText.concat('">Next→</a>');
} catch (err) { }
}
}
var postLinksText = '';
if (previousLinkText) {
postLinksText = previousLinkText.concat(postLinksText);
}
postLinksText = postLinksText.concat(backToTopLinkText);
if (nextLinkText) {
postLinksText = postLinksText.concat(nextLinkText);
}
var postLinksSection = '<br /><hr /><br /><div style="text-align: center; font-style: normal;">'+postLinksText+'<br /></div>';
document.getElementsByTagName("article")[0].insertAdjacentHTML('beforeend', postLinksSection);
}
}
else {
// Remove nofooterlinks text from homepage if displayed as part of post preview.
var bodyContent = document.getElementsByTagName("body")[0].innerHTML;
var newBodyContent = bodyContent.replace(/nofooterlinks/gi, "");
document.body.innerHTML = newBodyContent;
}
}
/* Insert Link to RSS Feed */
// Insert footer links on posts, but not on the homepage.
if (document.getElementById("post-body")) {
var emailForm = document.getElementById("emailsub");
if (emailForm && !isSubscribePage) {
var rssFeedText = '<div style="text-align: center; margin-bottom: 1em; font-style: italic;"><p>Follow this site via <a href="https://journal.dinobansigan.com/feed/" target="_blank">RSS Feed</a>, or subscribe via email using the form below.</p></div>';
document.getElementById("emailsub").insertAdjacentHTML('beforebegin', rssFeedText);
}
}
/* Add Subject to Mailto Link */
/*
if (document.getElementById("mailtolink")) {
var title = document.getElementById("title").innerHTML;
if (title) {
var newHref = "mailto:dino.journal@protonmail.com?subject=" + title;
document.getElementById("mailtolink").setAttribute("href", newHref);
}
}
*/
/* Show FB Share Button only when logged-in to write.as */
var isLoggedInToWA = currentURL.indexOf("https://write.as/dino/") != -1;
if (!isArchivePage && !isSearchPage && !isCommentsPage && !isSeriesAndTagsPage && !isAboutPage && !isSubscribePage &&
isLoggedInToWA && document.getElementById("post-body")) {
var shareUrl = currentURL.replace("write.as/dino", "journal.dinobansigan.com");
var shareText = '<iframe src="https://www.facebook.com/plugins/share_button.php?href=URLTOSHARE&layout=button&size=small&width=68&height=20&appId" width="68" height="20" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>';
shareText = shareText.replace("URLTOSHARE", shareUrl);
document.getElementsByTagName("article")[0].insertAdjacentHTML('beforeend', shareText);
}
/* Add Hyvor Talk Comments */
var HYVOR_TALK_WEBSITE = 0000; // REPLACE WITH YOUR 4 DIGITS
var HYVOR_TALK_CONFIG = {
url: false,
id: false
};
var hyvorTalkDiv = '<hr style="margin-top: 30px;" /><div id="hyvor-talk-view">Refresh this page if the comments box won't load.</div>'
if (document.getElementById("post-body") && !isArchivePage && !isSearchPage && !isCommentsPage && !isSeriesAndTagsPage && !isAboutPage && !isSubscribePage) {
document.getElementsByTagName("article")[0].insertAdjacentHTML('beforeend', hyvorTalkDiv);
}
// src: https://talk.hyvor.com/web-api/embed
/* Reading Time JS Widget */
var wpm = 200; // Average reading rate in words per minute (WPM)
var ps = document.querySelectorAll('p');
var wordCount = 0;
for (var i=0; i<ps.length; i++) {
wordCount += ps[i].innerText.split(/\s+/).length;
}
var $time = document.querySelector('#post-body .dt-published');
if ($time) {
var minuteToRead = Math.round(wordCount / wpm) > 0 ? Math.round(wordCount / wpm) : 1;
$time.style.display = 'inline-block';
$time.insertAdjacentHTML("afterend", '<span style="color: #666"> · ' + minuteToRead + ' min read</span>');
}
/* Custom Footer*/
var customFooterHTML = 'Copyright © 2019 - 2021 by <a class="home pubd" href="https://dinobansigan.com/" target="_blank">Dino Bansigan</a><br />The opinions expressed herein are my own and do not represent those of my employer<br />or any other third-party views in any way.<br />This work is licensed under <a class="home pubd" href="https://creativecommons.org/licenses/by-nc-sa/4.0?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;">CC BY-NC-SA 4.0<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/sa.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/nc.svg?ref=chooser-v1"></a><br />published with <a class="home pubd" href="https://write.as/">write.as</a>';
var x = document.querySelector('footer').getElementsByTagName('nav')[0];
x.innerHTML = customFooterHTML;
/* Remove Post Signatures on Pinned Pages */
/*
var y = document.getElementById("post-signature");
if (y && isArchivePage || isSearchPage || isCommentsPage || isSeriesAndTagsPage || isAboutPage || isSubscribePage) {
y.setAttribute("id", "post-signature-hidden");
}
*/
/* Remove Post Signatures on Home Page posts */
if (!document.getElementById("post-body")) {
var sigs = document.querySelectorAll("#post-signature");
var i;
for (i = 0; i < sigs.length; i++) {
sigs[i].setAttribute("id", "post-signature-homepage-hidden");
}
}
/* Custom Description*/
const customDescriptionHTML = 'A peek into the mind of a sleep deprived <a href="https://devblog.dinobansigan.com/" target="_blank">software developer</a>, husband, dad and <a href="https://journal.dinobansigan.com/tag:GameLog" target="_blank">gamer</a>.';
const desc = document.querySelector('header').getElementsByTagName('p')[0];
if (desc) {
desc.innerHTML = customDescriptionHTML;
}