Patreon - move likes to the likes button

Moves like counter next to like icon

Version vom 05.10.2020. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Patreon - move likes to the likes button
// @namespace    https://greasyfork.org/ru/users/303426-титан
// @version      1.0
// @description  Moves like counter next to like icon
// @author       You
// @match        https://www.patreon.com/*
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {
	'use strict';
	let update_time = 500;
	let disable_optimisation = false
	let page_loaded = true;
	let log = true;
	if (log) console.log("---PATREON: likes next to likes button----: started");


	function update() {
		if ($("div[data-tag=\"post-card\"]").length&&!$("svg[aria-label=\"loading more posts\"]").length) {
			if (!page_loaded) return;
			let postdetails = document.querySelectorAll("div[data-tag=\"post-details\"]");
			if (log) console.log("---PATREON: likes next to likes button----: updated");
			for (let postdetail of postdetails) {
				if (postdetail.getAttribute("likemoved")=="true") continue //skip if processed
				if (postdetail.firstChild.lastChild.previousSibling==null) continue;

				let likecountBlock = postdetail.firstChild.lastChild;
				let likecount = likecountBlock.firstChild.firstChild.innerHTML;
				let likebut = postdetail.firstChild.firstChild.firstChild.firstChild;
				likecount = parseInt(likecount.match(/\d+/));

				likecountBlock.firstChild.firstChild.innerHTML = likecount;
				likecountBlock.firstChild.style = "padding-top: 17px;";
				likebut.style = "width: 13px;";

				likebut.after(likecountBlock);
				postdetail.setAttribute("likemoved","true") //mark as processed
			}
			if (!disable_optimisation) page_loaded = false;
		} else { //if posts haven't been loaded yet
			if (!disable_optimisation) page_loaded = true;
			if (log) console.log("---PATREON: likes next to likes button----: waiting for load");
		}

		return;
	}


	setInterval(update, update_time);
})();