Created
March 12, 2021 20:37
-
-
Save Pross/8bdf51ad09e5760161bcb990ed1664ce to your computer and use it in GitHub Desktop.
right click thing.
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
(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