This is the result:
Thanks for this upgrade, it was absolutely necessary. Not knowing how many sMerits you still have when you are about to give one was not an option, given their overall scarcity (most people have just a few sMerits).
It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
// ==UserScript==
// @name bitcointalk merit
// @namespace grue
// @include https://bitcointalk.org/index.php?topic=*
// @require https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js
// @version 1.1-em0.1
// @downloadURL https://grue.blob.core.windows.net/scripts/Merit.user.js?sv=2014-02-14&si=1&sr=c&sig=k%2BqstGBI3oQ8TrHfPWjS5HgjrazuDPmKJ6rYNs7rvRk%3D&.user.js
// @grant none
// ==/UserScript==
(() => {
var sMerit;
//get csrf token from the logout link
let sc = $('td.maintab_back a[href*="index.php?action=logout;sesc="').attr("href");
sc = /;sesc=(.*)/.exec(sc)[1];
//Added by EcuaMobi: Get remaining sMerit
$.post(
"https://bitcointalk.org/index.php?action=merit;msg=29048068"
).then((data) => {
sMerit = /You have ([0-9]+)<\/b> sendable/.exec(data)[1];
}).catch(() => sMerit = null);
//selector for the "+Merit" link
$('td.td_headerandpost div[id^=ignmsgbttns] a[href*="index.php?action=merit;msg="]')
.each((i, e) => {
const msgId = /msg=([0-9]+)/.exec(e.href)[1];
const $popup = $(['','
' ',
'
].join("\n"));
$popup.find("form").submit( (e) => {
e.preventDefault();
$popup.find('input[type="submit"]')
.prop("disabled", true)
.val("Sending...");
const merits = e.target.elements["merits"].value;
$.post(
"https://bitcointalk.org/index.php?action=merit",
{merits, msgID: msgId, sc}
).then((data) => {
//Error pages usually have this (rough heuristic)
if(data.includes("An Error Has Occurred! throw "error";
}
//double check and see whether the post we merited was added to the list. Its msgId should be visible in the page source.
if(data.includes("#msg" + msgId)) {
alert("Merit added.");
$("#grue-merit-popup" + msgId).toggle(false);
// Added by EcuaMobi
if(sMerit!=null) { sMerit -= merits }
return;
}
alert("Server response indeterminate.");
})
.catch(() => alert("Failed to add merit."))
.always(() => {
$popup.find('input[type="submit"]')
.prop("disabled", false)
.val("Send");
});
});
$popup.insertAfter(e);
$(e).click((e) => {
e.preventDefault();
$("#grue-merit-popup" + msgId).toggle();
// Added by EcuaMobi
if(sMerit!=null) { $("#em-smerit-count" + msgId).html('Available: '+sMerit+' ') };
});
});
$(".grue-merit-popup").toggle(false);
})();
//get csrf token
var sc = $('input[name="sc"][type="hidden"]').val();
sc = (!sc ? ($('a[onclick]')[1].href).split('sesc=')[1] : sc);
//get csrf token
var sc = $('input[name="sc"][type="hidden"]').val();
sc = (!sc ? ($('a[onclick]')[1].href).split('sesc=')[1] : sc);
//get csrf token
var sc = $('input[name="sc"][type="hidden"]').val();
sc = (!sc ? ($('a[onclick]')[1].href).split('sesc=')[1] : sc);