Share what you are working on and using!

In preparation of coming out of my 2nd digital declutter, I’ve been trying to find ways to optimize how I use my music blog. One of the things I want to do is to share my post to my friends who are on FB. Since write.as doesn’t have a cross post option to FB, I do this manually. This means opening FB on my browser, creating a new FB post with a link to my blog post. I want to find ways to make this even quicker, possibly with me not even having to open up FB.

What I’ve come up with here, is a way to add an FB share button at the bottom of my posts. This button when clicked, will open up a new tab where all I have to do, is click the Post button and it will automatically share my blog post to FB. And after I click the Post button, it also automatically closes the new tab, which means I don’t even end up on FB after. This share button only shows up when I’m logged in, which means other readers won’t see it. This is perfect for me since I can quickly hit the share button after publishing a new post.

Here is the custom Javascript I am using:

/* Show FB Share Button only when logged-in to write.as */
var currentURL = window.location.href;
var isLoggedInToWA = currentURL.indexOf("https://write.as/now-listening-to/") != -1;
if (isLoggedInToWA && document.getElementById("post-body")) {
    var shareUrl = currentURL.replace("write.as/now-listening-to", "nowlisteningto.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);
}

You can replace the urls above to make it work on your site. Also, if you remove the script that checks for isLoggedInToWA, then you will have enabled the FB share button on all your posts, and your readers can click it and instantly share to FB.

Here is what it looks like at the bottom of a post on my music blog: