Bonsai
by
takenspc
2010-08-28 [2010/08/28 22:53:48]
hg.mozilla.org の pushloghtml に変更されたファイルの一覧を表示します。
@@ -28,16 +28,24 @@
data[link] = list;
}
- var target = document.querySelector('table tr:first-child > th:nth-child(3)');
- var th = document.createElement('TH');
- th.appendChild(document.createTextNode('Files'));
- target.parentNode.insertBefore(th, target);
+ var th = document.getElementById('files');
+ if (!th) {
+ document.createElement('TH');
+ th.appendChild(document.createTextNode('Files'));
+ th.setAttribute('id', 'files')
+ var el = document.querySelector('table tr:first-child > th:nth-child(3)');
+ el.parentNode.insertBefore(th, el);
+ }
for (var link in data) {
- var el = document.querySelector('a[href="' + link + '"]');
+ var el = document.getElementById(link);
+ if (el)
+ continue;
+ el = document.querySelector('a[href="' + link + '"]');
if (!el)
continue;
el = el.parentNode;
+ cell.setAttribute('id', link);
var cell = document.createElement('TD');
cell.appendChild(data[link]);
el.parentNode.insertBefore(cell, el.nextElementSibling);
/*
* @title Bonsai
* @description hg.mozilla.org の pushloghtml に変更されたファイルの一覧を表示します。
* @include http://hg.mozilla.org/*
* @license MIT License
* @require
*/
(function() {
function insertFileList(xml) {
var entries = xml.querySelectorAll('entry');
var data = {};
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
var link = entry.querySelector('link').getAttributeNS(null, 'href');
link = link.replace(/^http:\/\/hg\.mozilla\.org/, '');
link = link.replace(/\/([0-9a-f]{12})[0-9a-f]+$/, '/$1');
list = document.importNode(entry.querySelector('content > div > ul'), true);
var items = list.children;
for (var j = 0; j < items.length; j++) {
var item = items[j];
var a = document.createElement('A');
a.setAttribute('href', link.replace('/rev/', '/diff/') + '/' + item.textContent);
a.appendChild(item.firstChild);
item.appendChild(a);
}
data[link] = list;
}
var th = document.getElementById('files');
if (!th) {
document.createElement('TH');
th.appendChild(document.createTextNode('Files'));
th.setAttribute('id', 'files')
var el = document.querySelector('table tr:first-child > th:nth-child(3)');
el.parentNode.insertBefore(th, el);
}
for (var link in data) {
var el = document.getElementById(link);
if (el)
continue;
el = document.querySelector('a[href="' + link + '"]');
if (!el)
continue;
el = el.parentNode;
cell.setAttribute('id', link);
var cell = document.createElement('TD');
cell.appendChild(data[link]);
el.parentNode.insertBefore(cell, el.nextElementSibling);
}
}
var url = (window.location + '').replace('pushloghtml', 'pushlog');
var req = new XMLHttpRequest();
req.overrideMimeType('text/xml');
req.open('GET', url, true);
req.onreadystatechange = function(aEvent) {
if (req.readyState == 4) {
if (req.status == 200) {
insertFileList(req.responseXML);
}
}
};
req.send(null);})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。