Skip to content

Instantly share code, notes, and snippets.

@fsantini
Created February 26, 2020 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fsantini/432ba73bcb3fe12da39b323eb4078649 to your computer and use it in GitHub Desktop.
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
// ==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