Last active
October 6, 2015 02:01
-
-
Save EvaparotangCote/458892ec18f2482c90e5 to your computer and use it in GitHub Desktop.
Image dimensions before title. Thread: https://stackoverflow.com/questions/32949162/can-firefox-show-resolution-of-image-before-name-in-tab-title
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
// ==UserScript== | |
// @name Image dimensions before title | |
// @description Request by supasd. Code by wOxxOm. https://stackoverflow.com/a/32949363/5382305 | |
// @icon https://assets-cdn.github.com/images/icons/emoji/unicode/1f504.png | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
if (!changeTitle()) { | |
new MutationObserver(function(mutations) { | |
var nodes = mutations[0].addedNodes; | |
if (nodes[0] && nodes[0].localName == 'title' && changeTitle(nodes[0]) | |
|| document.body && document.body.children.length) { | |
this.disconnect(); | |
} | |
}).observe(document, {subtree: true, childList: true}); | |
} | |
document.addEventListener('DOMContentLoaded', changeTitle); | |
function changeTitle(node) { | |
var m = document.title | |
.match(/^(.+?\.\w+) \((?:([^,]+?), )?(\d+)\s*[x×]\s*(\d+)( \w+)?\)/); | |
if (m) { | |
document.title = m[3] + 'x' + m[4] + ' ' + m[1] + (m[2] ? ' (' + m[2] + ')' : ''); | |
return true; | |
} | |
} |
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
// ==UserScript== | |
// @name Image dimensions before title | |
// @description Request by supasd. Code by wOxxOm. https://stackoverflow.com/a/32949363/5382305 | |
// @icon https://assets-cdn.github.com/images/icons/emoji/unicode/1f504.png | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
var m = document.title | |
.match(/^(.+?\.\w+) \((?:([^,]+?), )?(\d+)\s*[x×]\s*(\d+)( .+?)?\)/); | |
if (m) | |
document.title = m[3] + 'x' + m[4] + ' ' + m[1] + (m[2] ? ' (' + m[2] + ')' : ''); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reproducible every single time (on Windows 8.1):
Firefox Nightly (44):
Greasemonkey 3.4.1:
Firefox Nightly (44):
Greasemonkey 3.5beta3: