Created
July 29, 2017 07:32
-
-
Save GeonoTRON2000/7f8ede2a6f5db7bb7eee68e1e4452333 to your computer and use it in GitHub Desktop.
A plugin to allow users to insert functional "Buy Now" buttons into a forum using Cash Mod.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var me = document.getElementById("brdwelcome").getElementsByTagName("strong")[0].innerHTML; | |
var j; | |
var posts = document.getElementsByClassName("postmsg"); | |
for (j = 0; j < posts.length; j++) { | |
var post = posts[j]; | |
var thishtml = post.innerHTML; | |
var buttons = []; | |
var i; | |
for (i = 0; i < thishtml.split("[buynow]").length-1; i++) { | |
buttons[i] = thishtml.split("[buynow]")[i+1].split("[/buynow]")[0]; | |
} | |
for (i = 0; i < buttons.length; i++) { | |
var username = buttons[i].split(",")[0]; | |
var amount = buttons[i].split(",")[1]; | |
if (amount != "x") | |
thishtml = thishtml.replace(/\[buynow\](.+?)\[\/buynow\]/i, "<form action=\"donate.php\" method=\"post\">\r\n<div style=\"display: none !important;\"><input type=\"submit\" name=\"submit\" value=\"Donate\" /></div>\r\n<input type=\"hidden\" name=\"username\" value=\""+username.replace(/"/g, "\'")+"\" />\r\n<input type=\"hidden\" name=\"amount\" value=\""+parseInt(amount)+"\" />\r\n<input type=\"button\" value=\"Buy Now\" onclick=\"if (window.confirm('Do you really want to buy this item from "+username+" for $"+amount+"?')) { this.form.submit.click(); }\">\r\n</form>"); | |
else | |
thishtml = thishtml.replace(/\[buynow\](.+?)\[\/buynow\]/i, "<form action=\"donate.php\" method=\"post\">\r\n<div style=\"display: none !important;\"><input type=\"submit\" name=\"submit\" value=\"Donate\" /></div>\r\n<input type=\"hidden\" name=\"username\" value=\""+username.replace(/"/g, "\'")+"\" />\r\n<input type=\"hidden\" name=\"amount\" value=\""+parseInt(amount)+"\" />\r\n<input type=\"button\" value=\"Buy Now\" onclick=\"var amt=parseInt(window.prompt('Enter amount to pay:'))+''; this.form.amount.value=amt; if (window.confirm('Do you really want to buy this item from "+username+" for however much you entered?')) { this.form.submit.click(); }\">\r\n</form>"); | |
} | |
post.innerHTML = thishtml; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment