Patreon - move likes to the likes button

Moves like counter next to like icon

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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       Титан
// @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);
})();