Created
January 29, 2009 06:47
-
-
Save edvakf/54425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name mata wikipedia yonderu | |
// @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 = 'matawikipe'; | |
object.style = 'visibility:hidden;position:fixed;height:1px;width:1px;top:0;left:0;'; | |
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'; | |
} | |
,180000); | |
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
What exactly does this script do?