This repository has been archived by the owner on May 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
facebook.com.js
51 lines (39 loc) · 1.52 KB
/
facebook.com.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// open graph redirect
// code from: https://raw.github.com/jodoglevy/open-graph-redirect/master/chrome/redirect.js
function getURLParameterByName(url, name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec(url);
if(results == null) return null;
else return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function replaceOpenGraphTags() {
var links, numLinks, i, redirectURI;
links = document.querySelectorAll('a[href*="connect/uiserver.php"]');
numLinks = links.length;
for (i = 0; i < numLinks; i++) {
redirectURI = getURLParameterByName( links[i].getAttribute('href'), "redirect_uri");
if (redirectURI) {
links[i].setAttribute('href', redirectURI);
links[i].removeAttribute('rel');
links[i].setAttribute('target', '_blank');
}
}
}
function checkForOpenGraphOAuth() {
if(document.URL.indexOf("dialog/oauth") !== -1) {
var redirectURI = getURLParameterByName( document.URL, "redirect_uri");
var scope = getURLParameterByName( document.URL, "scope");
if(redirectURI && scope && scope.indexOf("publish_actions") !== -1) {
window.location = redirectURI;
}
}
}
checkForOpenGraphOAuth();
replaceOpenGraphTags();
document.addEventListener('DOMSubtreeModified', replaceOpenGraphTags, false);
// remove 'friends on chat' box
$('#pagelet_friends_online').hide();
// remove chat dock
$('.fbDockWrapper').hide();