-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliffstarter.js
199 lines (191 loc) · 6.83 KB
/
liffstarter.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
window.onload = function (e) {
liff.init(function () {
getP();
});
};
function getP(){
var tipe = getParameterByName('type')
if (!tipe) {
document.getElementById('textx').addEventListener('click', function () {
liff.sendMessages([{
type: 'text',
text: 'LINE LIFF BY FGM INDONESIA',
sentBy: {
label: "FGM INDONESIA",
iconUrl: "https://i.ibb.co/GWNgT45/flag-u955f8b8f004bd259a9d64c1cc9336552.jpg",
linkUrl: "https://fgmid.xyz",
}
}]).then(function () {
liff.closeWindow();
});
});
document.getElementById('imagex').addEventListener('click', function () {
liff.sendMessages([{
type: 'text',
text: atob('bGluZTovL2FwcC8xNjAyNjg3MzA4LUdYcTRWdms5P3R5cGU9aW1hZ2UmaW1nPWh0dHBzOi8vd2FsbHBhcGVyc3R1ZGlvMTAuY29tL3N0YXRpYy93cGRiL3dhbGxwYXBlcnMvMTAwMHg1NjMvMTY4ODkxLmpwZwoKdHlwZSA9PiBpbWFnZQppbWcgPT4gTGluayAobXVzdCBiZSBIVFRQUyk=')
}]).then(function () {
liff.closeWindow();
});
});
document.getElementById('videox').addEventListener('click', function () {
liff.sendMessages([{
type: 'text',
text: atob('bGluZTovL2FwcC8xNjAyNjg3MzA4LUdYcTRWdms5P3R5cGU9dmlkZW8mb2N1PWh0dHBzOi8vdGlueXVybC5jb20veThvZzNvcjUmcGl1PWh0dHBzOi8vaW1hZ2VzNi5hbHBoYWNvZGVycy5jb20vNzEwL3RodW1iLTM1MC03MTAxMzIucG5nCgp0eXBlID0+IHZpZGVvCm9jdSA9PiB2aWRlbyB1cmwKcGl1ID0+IHByZXZpZXcgaW1hZ2U=')
}]).then(function () {
liff.closeWindow();
});
});
document.getElementById('audiox').addEventListener('click', function () {
liff.sendMessages([{
type: 'text',
text: atob('bGluZTovL2FwcC8xNjAyNjg3MzA4LUdYcTRWdms5P3R5cGU9YXVkaW8mbGluaz1odHRwczovL3BsYXRlbGV0cy5mdW4vcHVibGljL3NvdW5kcy9tdXNpYy5tcDM=')
}]).then(function () {
liff.closeWindow();
});
});
document.getElementById('stickerx').addEventListener('click', function () {
liff.sendMessages([{
type: 'text',
text: atob('V2l0aCBBbmltYXRpb246CmxpbmU6Ly9hcHAvMTYwMjY4NzMwOC1HWHE0VnZrOT90eXBlPXN0aWNrZXImc3RrPWFuaW0mc2lkPTMyMTI4MjMxJnBrZz0zMDk5MzEyCgpObyBBbmltYXRpb246CmxpbmU6Ly9hcHAvMTYwMjY4NzMwOC1HWHE0VnZrOT90eXBlPXN0aWNrZXImc3RrPW5vYW5pbSZzaWQ9MzIxMjgyMzEmcGtnPTMwOTkzMTIKCnR5cGUgPT4gc3RpY2tlcgpzdGsgPT4gYW5pbSAvIG5vYW5pbQpzaWQgPT4gc3RpY2tlciBpZApwa2cgPT4gcGFja2FnZXMgaWQ=')
}]).then(function () {
liff.closeWindow();
});
});
} else {
makeText();
makeImage();
makeVideo();
makeAudio();
makeSticker();
meProfile();
}
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
function getProfile(){
liff.getProfile().then(function (profile) {
document.getElementById('userid').textContent = 'Hai ' + profile.displayName;
document.getElementById('main').src = profile.pictureUrl;
document.getElementById('close').addEventListener('click', function () {
liff.closeWindow();
});
});
}
function makeText(){
var tipe = getParameterByName('type');
if (tipe === 'text') {
liff.sendMessages([{
type: 'text',
text: getParameterByName('text')
}]).then(function () {
liff.closeWindow();
});
}
}
function makeImage(){
var tipe = getParameterByName('type');
if (tipe === 'image') {
liff.sendMessages([{
type: 'image',
originalContentUrl: getParameterByName('img'),
previewImageUrl: getParameterByName('img')
}]).then(function () {
liff.closeWindow();
});
}
}
function makeVideo(){
var tipe = getParameterByName('type');
if (tipe === 'video') {
liff.sendMessages([{
type: 'video',
originalContentUrl: getParameterByName('ocu'),
previewImageUrl: getParameterByName('piu')
}]).then(function () {
liff.closeWindow();
});
}
}
function makeAudio(){
var tipe = getParameterByName('type');
if (tipe === 'audio') {
liff.sendMessages([{
type: 'audio',
originalContentUrl: getParameterByName('link'),
duration: 60000
}]).then(function () {
liff.closeWindow();
});
}
}
function makeSticker(){
var tipe = getParameterByName('type');
if (tipe === 'sticker') {
var stk = getParameterByName('stk');
var sid = getParameterByName('sid');
var pkg = getParameterByName('pkg');
var ep = '';
if (stk === 'anim') {
ep = "/IOS/sticker_animation@2x.png";
} else {
ep = "/IOS/sticker@2x.png";
}
liff.sendMessages([{
type: "template",
altText: "Sticker",
template: {
type: "image_carousel",
columns: [{
imageUrl: "https://stickershop.line-scdn.net/stickershop/v1/sticker/"+sid+ep,
action: {
type: "uri",
uri: "line://shop/sticker/detail/"+pkg}}
]
}
}]).then(function () {
liff.closeWindow();
});
}
}
function meProfile(){
var tipe = getParameterByName('type');
liff.getProfile().then(function (prof) {
var stat = prof.statusMessage;
if (stat == null) {
var stat = " - ";
}
if (stat.length > 60) {
var stat = "Status Message is to long! Max 60 words";
}
if (tipe === 'profile') {
liff.sendMessages([{
type: "template",
altText: "Profile "+prof.displayName,
template: {
type: "buttons",
thumbnailImageUrl: prof.pictureUrl,
imageAspectRatio: "square",
imageSize: "cover",
title: prof.displayName,
text: stat,
actions: [
{
type:"uri",
label:"Me",
uri:"line://app/1602687308-GXq4Vvk9?type=profile"
}
]
}
}]).then(function () {
liff.closeWindow();
});
}
});
}