This has happened to me several times, but the solution is simple:
After that, you can send merits, and if you want to resend, you will not be able to send them again (unless you refresh the page).
Personally, I do not see any need to modify the current version, as the number of such errors is less than 1%.
// ==UserScript==
// @name bitcointalk merit
// @version 1.3
// @author grue, minifrij, EcuaMobi, ETFbitcoin
// @source https://github.com/grue0/bitcointalk-scripts/
// @source https://bitcointalk.org/index.php?topic=2833350.0;0
// @description A very simple userscript that allows you to add merit without leaving the page
// @include https://bitcointalk.org/index.php?topic=*
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @grant none
// ==/UserScript==
(() => {
var sMerit, source_sMerit, check_onClick = false, oneClick_amount = [1, 2, 5, 10, 50]
function check_sMerit(msgId){
// Added by EcuaMobi
$.post(
"https://bitcointalk.org/index.php?action=merit;msg=29048068"
).then((data) => {
sMerit = /You have
([0-9]+)<\/b> sendable/.exec(data)[1]
source_sMerit = /The next ([0-9]+) merit you spend will come from your source/.exec(data)[1]
show_popup(msgId)
}).catch(() => sMerit = null)
}
function show_popup(msgId){
if(sMerit!=null && source_sMerit==null) {
$("#em-smerit-count" + msgId).html('Available: '+sMerit+' ')
} else if (sMerit!=null && source_sMerit!=null) {
$("#em-smerit-count" + msgId).html('Available (yours | source): '+sMerit+' | '+source_sMerit+' ')
}else{
$("#em-smerit-count" + msgId).html('Getting sMerit amount... ')
}
$("#grue-merit-popup" + msgId).toggle()
}
// 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];
// Get remaining sMerit
check_sMerit()
// 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]
let oneClick_html = `
One-click send :
`
oneClick_amount.forEach((amount) => {
oneClick_html += `
`
})
const $popup = $([''
].join("\n"))
$popup.find("form").submit( (e) => {
e.preventDefault()
$popup.find('.sendButton')
.prop("disabled", true)
.val("Sending...")
$popup.find('.oneClick')
.prop("disabled", true)
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)
if(!check_onClick){
if(source_sMerit!=null && source_sMerit-merits>=0){
source_sMerit -= merits
}else if(source_sMerit!=null && source_sMerit>0){
sMerit -= merits-source_sMerit
source_sMerit = 0
}else if(sMerit!=null){
sMerit -= merits
}
}
return
}
alert("Server response indeterminate.")
})
.catch(() => alert("Failed to add merit."))
.always(() => {
$popup.find('.sendButton')
.prop("disabled", false)
.val("Send")
$popup.find('.oneClick')
.prop("disabled", true)
})
})
$popup.insertAfter(e)
$(e).click((e) => {
e.preventDefault()
if(check_onClick){
check_sMerit(msgId)
}else{
show_popup(msgId)
}
})
})
$(".grue-merit-popup").toggle(false)
})()