Eyes Tool,用于Flickr的Greasemonkey脚本
2009年11月4日
| 标签: Firefox, Flickr, Greasemonkey, Javascript
因为要最近的eyes都是关于flickr的,而每次收集这样的图并通过wordpress发布是很麻烦的。于是想写一个脚本来完成一些工作。原本想的是用python来处理的,但是仔细想想,而且平时基本都是用Firefox在浏览网页,而且Greasemonkey都是必备扩展,使用Greasemonkey的效率更高,也可以再学习下Javascript。
// ==UserScript==
// @name Eyes Tool.Show image information for eyes.
// @namespace http://5.yupana.net
// @include *flickr.com/photos/*/*
// ==/UserScript==
function xPath (arg) {
return document.evaluate(
arg,document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
}
var images = xPath('//div[starts-with(@id,"photo")]//img');
var image = images.snapshotItem(0);
var titles = xPath('//meta[starts-with(@name,"title")]');
var title = titles.snapshotItem(0);
var url = window.location.href;
var text = '<strong>' + title.content + '<\/strong> <br /> <img title="' + title.content + '" src="' + image.src + '" alt="' + title.content + '" width="' + image.width + '" height="' + image.height + '" \/> <br /> <a href="' + url + '" target="_blank">' + url + '</a><br />';
var newdiv = document.createElement('div');
newdiv.innerHTML = text;
image.parentNode.appendChild(newdiv, image);
//======end===
发表评论
| Trackback
