Permalink
Browse files

add wkversion.js to show wk version number. closes #2.

  • Loading branch information...
myakura committed Apr 14, 2012
1 parent e8ac8fb commit 09bb6641814f08e3ae7cd9ddcccb3caa84b5acb2
Showing with 31 additions and 2 deletions.
  1. +2 −2 manifest.json
  2. +29 −0 wkversion.js
View
@@ -1,12 +1,12 @@
{
"name": "Dicentra",
- "version": "0.1",
+ "version": "0.2",
"description": "enhances WebKit changeset page.",
"manifest_version": 2,
"content_scripts": [{
"matches": [ "http://trac.webkit.org/changeset/*" ],
- "js": ["content.js" ],
+ "js": [ "content.js", "wkversion.js" ],
"run_at": "document_end"
}]
}
View
@@ -0,0 +1,29 @@
+(function () {
+ var url = location.href,
+ rechangeset = /^https?:\/\/trac\.webkit\.org\/changeset\/(\d+)$/;
+
+ if (!rechangeset.test(url)) return;
+ var revision = url.match(rechangeset)[1];
+
+ // path to Version.xcconfig
+ var pathtoconf = 'http://trac.webkit.org/export/' + revision + '/trunk/' +
+ (revision >= 75314 ? 'Source/' : '') +
+ 'WebCore/Configurations/Version.xcconfig';
+
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function () {
+ showVersion(xhr.response);
+ };
+ xhr.open('GET', pathtoconf);
+ xhr.send();
+
+ function showVersion(res) {
+ var revers = /MAJOR_VERSION = (\d+);\nMINOR_VERSION = (\d+);/;
+
+ if (!revers.test(res)) return;
+ var version = res.match(revers).slice(1);
+
+ document.querySelector('h1').textContent += ' (' + version.join('.') + ')';
+ }
+}());
+

0 comments on commit 09bb664

Please sign in to comment.