-
Notifications
You must be signed in to change notification settings - Fork 13
/
close.html
28 lines (23 loc) · 883 Bytes
/
close.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
layout: default
title: Getting Twitter Permissions
id: close-window
permalink: /close/
---
<script>
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
var response = [getUrlParameter('oauth_token'), getUrlParameter('oauth_verifier')];
//console.log('URL Reponse = ' + response);
window.addEventListener('message', function(event) {
if( response[0] === undefined || response[0] === '' || response.length == 0 ) {
event.source.postMessage('nothing', event.origin);
} else {
event.source.postMessage(response, event.origin);
}
},false);
</script>