Skip to content

Instantly share code, notes, and snippets.

@edvakf edvakf/gist:54424
Created Jan 29, 2009

Embed
What would you like to do?
// ==UserScript==
// @name mata opera de google
// @include http://*.wikipedia.org/wiki/*
// @include http://twitter.com/public_timeline?from=userjs
// ==/UserScript==
(function() {
if (location.href.indexOf('wikipedia.org')>0) {
var wikipe = function() {
var object = document.createElement('object');
object.id = 'mataoperadewikipe';
object.style = 'visibility:hidden;position:fixed;';
setTimeout(
function() {
object.addEventListener('load',
function() {
object.contentWindow.postMessage(encodeURIComponent([
'「'+document.title.replace(/ - Wikipedia.*?/,'')+'」',
location.href
].join(' ')), '*');
},false);
object.data = 'http://twitter.com/public_timeline?from=userjs';
}
,180);
document.body.appendChild(object);
}
document.addEventListener('load', wikipe, false);
} else if (location.host == 'twitter.com') {
document.addEventListener('message',
function(e) {
if (e.domain.indexOf('wikipedia.org')<0 ) return;
var url = 'http://twitter.com/statuses/update.json';
var x = new XMLHttpRequest();
x.open('POST', url, true);
x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
x.send('status=またWikipedia読んでる。' + e.data);
},
false);
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.