Skip to content

Instantly share code, notes, and snippets.

@prail
Last active August 2, 2020 18:37
Show Gist options
  • Save prail/dc0d24b14dfa29b3db13855fedc55982 to your computer and use it in GitHub Desktop.
Save prail/dc0d24b14dfa29b3db13855fedc55982 to your computer and use it in GitHub Desktop.
Simple userscript for commenting nice when you love a project.
// ==UserScript==
// @name magicFluffyUnicorn
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Does cool magic fluffy unicorn kind of stuff.
// @author @TheUltimatum, @bob1171
// @match https://scratch.mit.edu/projects/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
$(document).ready(function() {
$("#love-this").on("click", function() {
if ($(this).data("add") === true) {
$.ajax({
type: "POST",
url: "/site-api/comments/project/" + $(location).attr("href").split("/")[4] + "/add/",
data: JSON.stringify({ content: "nice!", parent_id: "", commentee_id: "" }),
success: function() { location.reload(); }
});
}
});
});
})();
@csf30816
Copy link

You should add

if ($(this).data("add") === true) {

After $("love-this").on(...

@prail
Copy link
Author

prail commented Aug 24, 2017

@csf30816 Ah! that's a good idea wasn't even thinking about that.

@kickofline
Copy link

what would that do?

@kickofline
Copy link

bitmoji

@kickofline
Copy link

haha bitmoji

@csf30816
Copy link

@bob1171 it would make it so the thing only sends the comment if you are liking it, not unliking it :)

@kickofline
Copy link

oh ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment