Personalized Tumblr-style button

Hey there, I've been working on creating a custom Tumblr-like button and tried adding an iframe above it to make it clickable. However, something seems to be off as it's not functioning properly. I'm still trying to wrap my head around how it all works, so please forgive me if this sounds like a silly question! From what I understand, you're supposed to create your own custom button and place Tumblr's iframe on top of it, but...

window.onload = function() {
  document.body.insertAdjacentHTML('beforeEnd', '<iframe id="my-like-frame" style="display:none;"></iframe>');
  document.addEventListener('click', function(event) {
    var myLike = event.target;
    if (myLike.className.indexOf('like') > -1) {
      var frame = document.getElementById('my-like-frame'),
        liked = (myLike.className == 'liked'),
        command = liked ? 'unlike' : 'like',
        reblog = myLike.getAttribute('data-reblog'),
        id = myLike.getAttribute('data-id'),
        oauth = reblog.slice(-8);
      frame.src = 'http://www.tumblr.com/' + command + '/' + oauth + '?id=' + id;
      liked ? myLike.className = 'like' : myLike.className = 'liked';
    };
  }, false);
};
.controls i {
  height: 10px;
  width: 10px;
  background: #ce9c87;
  border-radius: 100%;
  padding: 5px;
  display: block;
  overflow: visible;
  text-align: center;
  color: #fff;
  -webkit-transition: .2s ease;
  -moz-transition: .2s ease;
  -o-transition: .2s ease;
  transition: .2s ease;
}

.controls {
  float: right;
  margin-right: 10px;
}

.controls a {
  position: relative;
  display: inline-block;
  overflow: hidden;
  padding: 1px 2px;
  width: auto;
  height: auto;
  margin-left: 1em;
  float: right;
}

.like {
  position: relative;
  display: inline-block;
  overflow: hidden;
  padding: 1px 2px;
  width: auto;
  height: auto;
  margin-left: 1em;
  float: right;
  cursor: pointer;
}

.controls .like .liked+i,
.controls i:hover {
  color: #ce9c87;
  background-color: #fff;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<div class="controls">
  <a href="{Permalink}" class="permalink">
    <i class="fa fa-bookmark-o" aria-hidden="true"></i>
  </a>
  <a href="{ReblogURL}" target="_blank" class="reblog">
    <i class="fa fa-retweet" aria-hidden="true"></i>
  </a>
  <div class="like" data-reblog="{ReblogURL}" data-id="{PostID}">{LikeButton}
    <i class="fa fa-heart-o" aria-hidden="true"></i>
  </div>
</div>

If you need further clarification, feel free to check out this link for the page.

Thank you!

Answer №1

It seems like the issue you're facing is due to Tumblr's recent change in their policy, which no longer allows users to like posts on their own blogs. However, there is a workaround for this problem - simply open the console and click the like button. If an error message pops up, it means that your like button is functioning properly but Tumblr is blocking likes on your own posts.

https://i.sstatic.net/kuWSY.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Avoiding unnecessary re-renders of a parent component caused by a child component

I'm facing rendering problems and would greatly appreciate any assistance. I attempted to use useMemo and useCallback, but it resulted in the checkbox breaking. Within a component, I am displaying information from an object. Let's consider the fo ...

I am experiencing an issue where the Javascript keydown event does not recognize the character "@" in the EDGE browser

Currently, I am developing a mentioning directive that displays a list of users when the user types in an input field (a div with contentEditable=true). The user can then insert the name of the desired user in a specific format. The list is supposed to be ...

Transferring map functionality to a separate file

Is it possible to export the function inside the orders.map, specifically 'order', and then import it into another JS file with a function inside? I keep receiving an error that order is not defined. Thank you main.js const getReport = asy ...

The efficiency of XSL Template is significantly impacting loading time

Hello there, I am facing a challenge with my webpage's loading speed due to the code provided below. Can you assist me in optimizing it? <xsl:template match="Category" mode="CategorySelectorScript"> <xsl:variable name="ThisCateg ...

Is there a way for me to calculate the square of a number generated by a function?

Just starting out with Javascript and coding, I'm having trouble squaring a number that comes from a function. I've outlined below what I am trying to achieve. Thank you in advance for your help. // CONVERT BINARY TO DECIMAL // (100110)2 > ( ...

Converting a momentjs datetime stored in MySQL in UTC format to local DateTime format

I have a column in my table named "registerdate" with the data type "datetime" in MySQL. Let's assume the current time is "2015-10-10 06:00:00" in local time. In the database, I am storing UTC time, so it will be converted to "2015-10-10 00:30:00" a ...

What value does the "left" property default to?

When attempting to change the 'left: 0' property to 'left:none', I found that it did not work. Other properties such as margin and padding do work when overwritten. I aim to find a solution for this problem without altering the origina ...

In Outlook, images are always shown in their true dimensions

While everything is working perfectly fine in Gmail, Yahoo, and Hotmail, there seems to be an issue with the display of the logo image on Outlook. The custom width and height settings are not being applied properly, resulting in the logo being displayed ...

How to send arguments to an external JavaScript file with JavaScript

In the header of my HTML document, I have included the following script: <script src="http://www.domain.com/js/widgets.js" type="text/javascript"></script> This script references: widgets.js (function () { var styleEl = document.create ...

Ember - connecting to a JSON data source

Recently, I have been following a tutorial/example from codeschool and everything is going well. However, the example code includes the line: App.ApplicationAdapter = DS.FixtureAdapter.extend(); Now, I want to maintain all the existing functionality but ...

The Javascript functionality does not seem to be functioning properly within the Bootstrap navigation

I'm having an issue with my Bootstrap navbar JavaScript. Below is the code that's causing the problem: <script type="text/javascript"> $(".nav a").on("click", function () { $(".nav").find(".active").removeClass("active"); $(this).p ...

The smooth transition of my collapsible item is compromised when closing, causing the bottom border to abruptly jump to the top

Recently, I implemented a collapsible feature using React and it's functioning well. However, one issue I encountered is that when the collapsible div closes, it doesn't smoothly collapse with the border bottom moving up as smoothly as it opens. ...

What measures can be taken to prohibit a user from accessing a client-side HTML file using express?

I am currently developing a task management application called "todolist." In my node.js code, I utilize express and grant it access to my directory named Client: var app = express(); app.use(express.static(__dirname + "/Client")); The contents of my Cl ...

Developing a unified input element containing numerous fields

After @grateful answered this question, I wanted to elaborate in case it could benefit others... In my project, there's a page called rsetup.php which has some PHP code to access a MySQL database for filling the HTML content of the page. This HTML ge ...

How to display a div in Angular when hovering with ElementRef and Query List

I am having trouble implementing a ngFor loop in my project where I want to display a div on mouse hover using the @Input notation. This is how my HTML code looks: <div class="col s12 m6" style="position: relative" *ngFor="let res of hostInfo.resident ...

Problems with form functionality in React component using Material UI

Trying to set up a signup form for a web-app and encountering some issues. Using hooks in a function to render the signup page, which is routed from the login page. Currently, everything works fine when returning HTML directly from the function (signup), ...

Choosing the content within a div and inserting it into an email

I have an email sender feature on my website where users can fill out input fields and hit send, resulting in me receiving an email. The text from all the input boxes is included in the email body. Additionally, there are some generated texts in divs with ...

Using Firebase onDisconnect with React Native

I am currently working on a React Native app and I am facing an issue where I need to update the user status to 'offline' in Firebase when the user closes the app. Here is what I have tried: import React, { Component } from 'react' ...

Utilize AngularJS to monitor the amount of time users spend within the web application and automatically activate an event at designated intervals

Is there a way to monitor how long a user is active on the website and trigger an event once they reach 30 seconds of browsing time? ...

What could be causing the form body to return null in a PUT request?

What could be causing the form data to not be stored in req.body? EJS/HTML <form onsubmit="EditJob()" class="editForm"> <div class="form-group-edit"> <label for="position">Position</label> <input type="pos ...