Skip to content

Instantly share code, notes, and snippets.

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 EvaparotangCote/458892ec18f2482c90e5 to your computer and use it in GitHub Desktop.
Save EvaparotangCote/458892ec18f2482c90e5 to your computer and use it in GitHub Desktop.
// ==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;
}
}
// ==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] + ')' : '');
})();
@EvaparotangCote
Copy link
Author

Reproducible every single time (on Windows 8.1):
Firefox Nightly (44):
Greasemonkey 3.4.1:

Using Firefox Nightly (44) or Firefox Developer Edition (43) produces the same results.
Though in Firefox Nightly (44) using Greasemonkey 3.4.1, in step 3., clicking 'Use Script From Clipboard' adds the userscript right away. No Scratchpad window pops up, so no need to click 'Save' and close Scratchpad window. Trying to edit the userscript by clicking 'Options' - 'Edit This User Script' does nothing - the userscript can't be edited. 

Firefox Nightly (44):
Greasemonkey 3.5beta3:

Using Greasemonkey 3.5beta3 or 3.4.1 produces the same results on Firefox Nightly (44).
Though in Firefox Nightly (44) using Greasemonkey 3.5beta3 - yeah well it works the same as in Firefox Developer Edition (43). It's just that using Firefox Nightly (44) with Greasemonkey 3.4.1 doesn'tt as noted above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment