-
-
Notifications
You must be signed in to change notification settings - Fork 226
/
Copy pathget_id_post_from_url_FB.js
90 lines (89 loc) · 2.45 KB
/
get_id_post_from_url_FB.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
javascript:
var currentLocation = window.location.href;
var string_url = currentLocation.split("/");
function fail(){
alert("Bạn phải ở đúng trang đã");
}
function copy(id){
var b=document.createElement("textarea"),c=document.getSelection();
b.textContent=id,document.body.appendChild(b),c.removeAllRanges(),b.select(),document.execCommand("copy"),c.removeAllRanges(),document.body.removeChild(b)
};
function getAllUrlParams() {
var queryString = currentLocation ? currentLocation.split('?')[1] : window.location.search.slice(1);
var obj = {};
if (queryString) {
queryString = queryString.split('#')[0];
var arr = queryString.split('&');
for (var i=0; i<arr.length; i++) {
var a = arr[i].split('=');
var paramNum = undefined;
var paramName = a[0].replace(/\[\d*\]/, function(v) {
paramNum = v.slice(1,-1);
return '';
});
var paramValue = typeof(a[1])==='undefined' ? true : a[1];
paramName = paramName.toLowerCase();
if (obj[paramName]) {
if (typeof obj[paramName] === 'string') {
obj[paramName] = [obj[paramName]];
}
if (typeof paramNum === 'undefined') {
obj[paramName].push(paramValue);
}
else {
obj[paramName][paramNum] = paramValue;
}
}
else {
obj[paramName] = paramValue;
}
}
}
return obj;
}
function getPost(){
try{
if(currentLocation.indexOf("/permalink/") !== -1){
var id = string_url[6];
if(id!="null") return id;
else return "0";
}
else if(currentLocation.indexOf("posts") !== -1){
var id = string_url[5];
if(id!="null") return id;
else return "0";
}
else if(currentLocation.indexOf("videos") !== -1){
var id = string_url[string_url.length-2];
if(id!="null") return id;
else return "0";
}
else if(currentLocation.indexOf("fbid=") !== -1){
var id = getAllUrlParams().fbid;
if(id!="null") return id;
else return "0";
}
else if(currentLocation.indexOf("/photos/") !== -1){
var id = string_url[6];
if(id!="null") return id;
else return "0";
}
else if(currentLocation.indexOf("m.facebook") !== -1){
var id = getAllUrlParams().id;
if(id!="null") return id;
else return "0";
}
return 0;
}
catch (e){
return 0;
}
}
var id = getPost();
if(id!="0" && id!="1" && isNaN(id)==false){
alert("Được phát triển bởi kiểm duyệt viên J2Team Community\nĐã copy!");
copy(id);
}
else if(id!="1"){
fail();
}