Skip to content

Instantly share code, notes, and snippets.

@kotobukid
Forked from hirataya/17sai.user.js
Last active December 16, 2015 13:39
Show Gist options
  • Save kotobukid/5443567 to your computer and use it in GitHub Desktop.
Save kotobukid/5443567 to your computer and use it in GitHub Desktop.
// -*- coding: utf-8 -*-
// ==UserScript==
// @name They are all 17 years old
// @author HIRATA Yasuyuki <yasu@asuka.net>
// @namespace http://yasu.asuka.net/
// @version 1.0
// @include http://www.google.tld/search?*
// @include https://www.google.tld/search?*
// @released 2013-04-23
// @updated
// ==/UserScript==
(function(){
var members = {
"井上喜久子": 17,
"田村ゆかり": 17,
"野川さくら": 17,
"佐藤利奈": 17,
"堀江由衣": 17,
"石田燿子": 17,
"松澤由美": 17,
"こやまきみこ": 17,
"池澤春菜": 17,
"たかはし智秋": 23,
"motsu": 18
};
var subjectNodes =
document.evaluate(
'//div[contains(concat(" ", normalize-space(@class), " "), " answer_subject ")]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
).snapshotItem(0);
var predicateNodes =
document.evaluate(
'//div[contains(concat(" ", normalize-space(@class), " "), " answer_predicate ")]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
).snapshotItem(0);
if(subjectNodes && predicateNodes) {
var subjectNode = subjectNodes.childNodes[0];
var predicateNode = predicateNodes.childNodes[0];
if(subjectNode.nodeValue.match(/(.*)\s*,\s*年齢/)) {
var age = members[RegExp.$1];
if(age) {
predicateNode.nodeValue =
predicateNode.nodeValue.replace(/^\d+歳/, age + "歳");
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment