Skip to content

Instantly share code, notes, and snippets.

@orangain
Created May 27, 2012 09:12
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 orangain/2802982 to your computer and use it in GitHub Desktop.
Save orangain/2802982 to your computer and use it in GitHub Desktop.
西宮市市民交流センター予約ページの改良
// ==UserScript==
// @name 西宮市市民交流センター予約ページの改良
// @namespace capybala.com
// @description
// @include http://nnpo.or.jp/rsv/calendar_all.cgi*
// ==/UserScript==
var getElementsByXPath = function(expression, parentElement) {
var r = []
var x = document.evaluate(expression, parentElement || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
for (var i = 0, l = x.snapshotLength; i < l; i++) {
r.push(x.snapshotItem(i))
}
return r
}
var rooms = [
{'name': '体育室' , 'limit': '20' , 'price': 1200, 'picture': '01.html#im-t'},
{'name': 'A会議室', 'limit': '10' , 'price': 400, 'picture': '02.html#im-a'},
{'name': 'B会議室', 'limit': '40' , 'price': 1400, 'picture': '02.html#im-b'},
{'name': 'C会議室', 'limit': '12' , 'price': 500, 'picture': '02.html#im-c'},
{'name': 'ホール' , 'limit': '110', 'price': 2900, 'picture': '02.html#im-h'},
{'name': 'D会議室', 'limit': '10' , 'price': 400, 'picture': '03.html#im-d'},
{'name': 'E会議室', 'limit': '6' , 'price': 200, 'picture': '03.html#im-e'},
{'name': 'F会議室', 'limit': '12' , 'price': 500, 'picture': '03.html#im-f'},
{'name': 'G会議室', 'limit': '24' , 'price': 700, 'picture': '01.html#im-g'},
{'name': '和室' , 'limit': '30' , 'price': 900, 'picture': '03.html#im-w'},
{'name': '調理室' , 'limit': '15' , 'price': 500, 'picture': '03.html#im-cho'},
{'name': '茶室' , 'limit': '8' , 'price': 400, 'picture': '03.html#im-cha'},
];
for (var i = 0; i < rooms.length; i++) {
var room = rooms[i];
var tds = getElementsByXPath('//td[text()="' + room.name + '"]');
for (var j = 0; j < tds.length; j++) {
var td = tds[j];
td.setAttribute('style', 'text-align: center');
td.appendChild(document.createElement('br'));
td.appendChild(document.createTextNode(room.limit + '人'));
td.appendChild(document.createElement('br'));
td.appendChild(document.createTextNode(room.price + '円'));
td.appendChild(document.createElement('br'));
var a = document.createElement('a');
a.setAttribute('href', '/rsv/' + room.picture);
a.appendChild(document.createTextNode('写真'));
td.appendChild(a);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment