Last modified: 2008-07-08 20:44:28 UTC
For writing userscripts (e.g. Greasemonkey scripts) it is essential for a script to detect if a page has been generated by MediaWiki software. Currently there is no indicator, neither in the head section nor in the body code which under full control of the many different standard or custom skins. I ran into this problem when I made the MediaWiki editor wikEd (http://en.wikipedia.org/wiki/User:Cacycle/wikEd) Greasemonkey compatible. Currently the program has to check the DOM for the fingerprints of many different skins. This causes problems with as yet unrecognized custom skins and changes. Writing extensions would be much easier with a unique identifier for MediaWiki-served web pages. This identifier could be in the head section and could also include the version of the software.
What does this request mean?
(In reply to comment #1) > What does this request mean? From what I gather, the reported wants a meta tag, comment, or some other standardized fingerprint indicating an HTML page was generated by MediaWiki. Basically, we could have OutputPage add <!-- Generated by MediaWiki version 1.11.0 --> near the top of the output.
Yes, that's about what I was suggesting. However, comments are somewhat difficult to access using JavaScript methods as far as I can see. Therfore I would prefer a 'real' element such as meta, div, or span.
(In reply to comment #3) >Therefore I would prefer a 'real' element such as meta, div, > or span. <meta> is probably best for this purpose.
WordPress does a <meta> like this: <meta name="generator" content="WordPress 2.2.3" /> <!-- leave this for stats --> Sound about right? I'm a little leery of including version information, as we deliberately don't want that bulk-searchable as an obfuscation to make it harder for potential worms to find vulnerable versions of the software via search engines.
Brion: The version is already available on Special:Version - I have actually used this successfully to google for older installations. If there is an option to disable the version number on Special:Version, then use the same setting to disable it for the meta tag, but keep the "MediaWiki" string.
Special:Version is explicitly excluded from search by meta tag. That's a whole page, not an individual piece of the page which is aimed specifically at being searchable.
I do not think that you can use search engines to find information hidden in meta tags - and worms crawling for vulnerable versions can always access special:version.
Please could somebody take care of this. New and custom skins are constantly added to Wikipedia (e.g. Modern) as well as other sites and everytime scripts have to be manually updated because there is still no simple and reliable Mediawiki identifier on the pages.
Created attachment 4588 [details] Adds a generator meta tag to the head of all MediaWiki pages This adds a meta tag to the head scripts in OutputPage, which should theoretically be included in all skins output. The identifier is in the generator tag and is in the format "MediaWiki <version>" so that it could easily be checked by JavaScript or any other user agent.
Please, could this be added as soon as possible. I can barely keep up with maintaining existing and writing new skin detections. If there are still objections about the version number, then please add at least the 'MediaWiki' part.
can't you simple check for a js variable or function that will always be there for mediawiki pages? wgPageName comes to mind. Even wgVersion exists.
And isn't the current skin even given in the variable aptly named skin?
JavaScript code on the pages is just on option that has to be enabled explicitly ($wgAllowUserJs). Many wikis do not enable this, e.g. for security reasons. Therefore, checking for JavaScript code is neither a reliable way to test for a MediaWiki generated page nor for identifying the used skin.
No, I'm pretty sure it's there regardless: http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/Skin.php WRT: makeGlobalVariablesScript
See here for a MediaWiki 1.11.0 installation that does not generate the JavaScript code: http://wiki-beta.moztw.org/Special:Version. Is it a recent 1.11.1 change or have they disabled it somehow.
(In reply to comment #16) > See here for a MediaWiki 1.11.0 installation that does not generate the > JavaScript code: http://wiki-beta.moztw.org/Special:Version. Is it a recent > 1.11.1 change or have they disabled it somehow. I think they removed the JavaScript code when creating their custom skin. As there's nothing you can do about that and the suggested methods will work for all "normal" skins, I suggest that this bug be closed.
MW version is identifiable by both the wgVersion JS variable and the <meta> generator tag, closing as FIXED.