Skip to content

Instantly share code, notes, and snippets.

@edvakf
Created January 29, 2009 06:47
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 edvakf/54424 to your computer and use it in GitHub Desktop.
Save edvakf/54424 to your computer and use it in GitHub Desktop.
// ==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