Created
February 26, 2020 16:05
-
-
Save fsantini/432ba73bcb3fe12da39b323eb4078649 to your computer and use it in GitHub Desktop.
Tampermonkey script to save the open Facebook image with a Ctrl-Alt-S shortcut
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
// ==UserScript== | |
// @name FBSavePic | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Save the open Facebook image with a Ctrl-Alt-S shortcut | |
// @author You | |
// @match https://www.facebook.com/* | |
// @require http://code.jquery.com/jquery-3.3.1.min.js | |
// @grant GM_download | |
// ==/UserScript== | |
var outDir = 'FBDownload/'; | |
(function($) { | |
'use strict'; | |
function saveCurrentPic() | |
{ | |
var imgTag = $("img.spotlight"); | |
var src = imgTag.prop("src"); | |
var jpgRe = /[^/]+\.jpg/ | |
var imgName = jpgRe.exec(src); | |
console.log(outDir + imgName[0]); | |
var savePath = outDir + imgName[0]; | |
GM_download({url: src, name: savePath, saveAs: false}); | |
console.log("Image saved as: " + savePath); | |
} | |
// Your code here... | |
document.onkeydown = function(e){ | |
// if (e.altKey) console.log("Alt pressed"); | |
//console.log("Key pressed"); | |
//console.log(e.keyCode); | |
if (e.altKey && e.ctrlKey && e.keyCode == 83) { | |
//console.log("Ctrl-Alt-S pressed"); | |
saveCurrentPic(); | |
} | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment