NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name PicturePaste // @namespace iliazeus.com // @description Looks for picture "descriptions" in message inputs that end with an image file extension (e.g. "facepalm.jpg"), then swaps them with actual URLs of the images. // @include http://vk.com/* // @include https://vk.com/* // @version 1 // @grant none // ==/UserScript== var trigger = /\b(\w+)(\.jpg|\.gif|\.png)/g; var subst = { 'facepalm.jpg': 'http://i.imgsafe.org/e1ef84aafe.jpg', 'doge.jpg': 'http://i.imgsafe.org/e1ef51ab15.jpg' }; var replace_func = function (match) { console.log('replaced ' + match + ' for ' + subst[match]); return subst[match] || match; }; var substitute = function (area) { area.innerHTML = area.innerHTML.replace(trigger, replace_func); } var keydown_handler = function (event) { if (!(event.ctrlKey && event.key == ' ')) return; substitute(event.target); } for (let area of document.getElementsByClassName('im_editable')) { area.onkeydown = keydown_handler; }