Skip to content

Instantly share code, notes, and snippets.

@TerrorBite
Last active April 1, 2017 09:44
Show Gist options
  • Save TerrorBite/233fe070aaf749ea7314b86d35cd142c to your computer and use it in GitHub Desktop.
Save TerrorBite/233fe070aaf749ea7314b86d35cd142c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Place Save Button
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Adds a save button to /r/place.
// @supportURL https://www.reddit.com/message/compose/?to=TerrorBite
// @author /u/TerrorBite
// @match https://*.reddit.com/place
// @match https://*.reddit.com/place?*
// @match https://*.reddit.com/r/place/
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Button click handler
var savePlaceCanvas = function() {
// Derive filename
var filename = "place_" + (new Date().toISOString().split('.')[0].replace(/[:-]/g,"").replace('T','_')) + ".png";
// Obtain image as data URL
var imageURL = $("#place-canvasse")[0].toDataURL();
// Trigger image download
$("<a>").attr("href", imageURL).attr("download", filename)[0].click();
};
// Create button and assign handler
$('<button class="place-mute-button">').css({
"transform":"translate(0, 48px)",
"background-image":"none",
"color":"white",
"font-size":"200%"
}).text("💾").appendTo("#place-container").click(savePlaceCanvas);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment