Created
June 23, 2017 11:44
-
-
Save koteq/8157600a00f8af74f6fb0a192c08427b to your computer and use it in GitHub Desktop.
G+ hover image title
This file contains hidden or 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 G+ hover image title | |
// @version 1.0 | |
// @match *://plus.google.com/* | |
// @run-at document-end | |
// @grant none | |
// ==/UserScript== | |
/* jshint esnext: true */ | |
const decodeFileName = (src) => { | |
return decodeURIComponent(decodeURIComponent(src.split('/').pop().split(/[\?#]/)[0])).replace(/[\+_]/g, ' '); | |
}; | |
document.body.addEventListener('mouseover', (e) => { | |
const t = e.target; | |
if (t && t.tagName && t.tagName === 'IMG' && t.src && !t.title && t.width > 160 && t.height > 120) { | |
const img = e.target; | |
img.title = decodeFileName(img.src); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment