Skip to content

Instantly share code, notes, and snippets.

@Pross
Created March 12, 2021 20:37
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 Pross/8bdf51ad09e5760161bcb990ed1664ce to your computer and use it in GitHub Desktop.
Save Pross/8bdf51ad09e5760161bcb990ed1664ce to your computer and use it in GitHub Desktop.
right click thing.
(function($) {
var overlayText = 'Dont steal my godamn images!';
var padding = '30px 20px';
var background = 'black';
var textColor = 'white';
$(document).ready(function() {
$('img').on('contextmenu',function(e){
var image = $(e.target),
wrap = image.parent();
wrap.css('display', 'flex').css('flex-direction', 'column').css('position', 'relative');
image.after('<span class="overlay-text">' + overlayText + '</span>');
text = wrap.find('span');
text.css('position', 'absolute').css('left', '50%').css('top', '50%').css('transform', 'translate(-50%, -50%)').css('color', textColor).css('background', background).css('padding', padding)
return false;
});
$('body').on('click', function(){
$('span.overlay-text').remove();
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment