429 lines
10 KiB
JavaScript
429 lines
10 KiB
JavaScript
window.onload = function (_0xe315c8) {
|
|
liff
|
|
.init({
|
|
liffId: '1657715144-m4W6lyjL', // Use own liffId
|
|
})
|
|
.then(() => {
|
|
if (!liff.isLoggedIn()) {
|
|
liff.login({ redirectUri: location.href });
|
|
} else {
|
|
getParameter();
|
|
}
|
|
});
|
|
};
|
|
function getParameter() {
|
|
var type = getParameterByName("type");
|
|
if (!type) {
|
|
document.getElementById("textx").addEventListener("click", function () {
|
|
const data = [{
|
|
type: "text",
|
|
"text": atob("bGluZTovL2FwcC8xNTk5NzA2MzkxLVh3a0JMNzg5P3R5cGU9dGV4dCZ0ZXh0PVlvdXIlMjBUZXh0DQoNCnR5cGUgPT4gdGV4dA0KdGV4dCA9PiB5b3VyIHRleHQ=")
|
|
}];
|
|
|
|
sendMessages(data);
|
|
});
|
|
document.getElementById("imagex").addEventListener("click", function () {
|
|
const data = [{
|
|
"type": "text",
|
|
"text": ("https://liff.line.me/1657715144-m4W6lyjL?type=image&img=https://wallpaperstudio10.com/static/wpdb/wallpapers/1000x563/168891.jpg\n\ntype => image\nimg => Link (must be HTTPS)")
|
|
}];
|
|
|
|
sendMessages(data);
|
|
});
|
|
document.getElementById("videox").addEventListener("click", function () {
|
|
const data = [{
|
|
"type": "text",
|
|
"text": ("https://liff.line.me/1657715144-m4W6lyjL?type=video&ocu=https://tinyurl.com/y8og3or5&piu=https://images6.alphacoders.com/710/thumb-350-710132.png\n\ntype => video\nocu => video url\npiu => preview image")
|
|
}];
|
|
|
|
sendMessages(data);
|
|
});
|
|
document.getElementById("audiox").addEventListener("click", function () {
|
|
const data = [{
|
|
"type": "text",
|
|
"text": ("https://liff.line.me/1657715144-m4W6lyjL?type=audio&link=https://platelets.fun/public/sounds/music.mp3")
|
|
}];
|
|
|
|
sendMessages(data);
|
|
});
|
|
document.getElementById("stickerx").addEventListener("click", function () {
|
|
const data = [{
|
|
"type": "text",
|
|
"text": ("With Animation:\nhttps://liff.line.me/1657715144-m4W6lyjL?type=sticker&stk=anim&sid=32128231&pkg=3099312\n\nNo Animation:\nhttps://liff.line.me/1657715144-m4W6lyjL?type=sticker&stk=noanim&sid=32128231&pkg=3099312\n\ntype => sticker\nstk => anim / noanim\nsid => sticker id\npkg => packages id")
|
|
}];
|
|
|
|
sendMessages(data);
|
|
});
|
|
} else {
|
|
document.body.innerHTML = "";
|
|
makeText();
|
|
makeImage();
|
|
makeVideo();
|
|
makeAudio();
|
|
makeSticker();
|
|
meProfile();
|
|
makeTest();
|
|
// makeDouDou();
|
|
makeBW();
|
|
}
|
|
}
|
|
function getParameterByName(stringParam, window_href) {
|
|
const URLscheme = {};
|
|
let urlsearch = window.location.search;
|
|
if (urlsearch.indexOf("?") !== -1) {
|
|
let str = urlsearch.substring(1);
|
|
let strs = str.split("&");
|
|
for (let i = 0; i < strs.length; i++) {
|
|
URLscheme[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
|
|
}
|
|
}
|
|
return URLscheme[stringParam];
|
|
}
|
|
function getProfile() {
|
|
liff.getProfile().then(function (data) {
|
|
document.getElementById("userid").textContent = "Hai " + data.displayName;
|
|
document.getElementById("main").src = data.pictureUrl;
|
|
document.getElementById("close").addEventListener("click", function () {
|
|
liff.closeWindow();
|
|
});
|
|
});
|
|
}
|
|
function makeText() {
|
|
var type = getParameterByName("type");
|
|
if (type === "text") {
|
|
const data = [{
|
|
"type": "text",
|
|
"text": getParameterByName("text")
|
|
}];
|
|
|
|
sendMessages(data);
|
|
}
|
|
}
|
|
function makeImage() {
|
|
var type = getParameterByName("type");
|
|
if (type === "image") {
|
|
const data = [{
|
|
"type": "image",
|
|
"originalContentUrl": getParameterByName("img"),
|
|
"previewImageUrl": getParameterByName("img")
|
|
}];
|
|
|
|
sendMessages(data);
|
|
}
|
|
}
|
|
function makeVideo() {
|
|
var type = getParameterByName("type");
|
|
if (type === "video") {
|
|
const data = [{
|
|
"type": "video",
|
|
"originalContentUrl": getParameterByName("ocu"),
|
|
"previewImageUrl": getParameterByName("piu")
|
|
}];
|
|
|
|
sendMessages(data);
|
|
}
|
|
}
|
|
function makeAudio() {
|
|
var type = getParameterByName("type");
|
|
if (type === "audio") {
|
|
const data = [{
|
|
"type": "audio",
|
|
"originalContentUrl": getParameterByName("link"),
|
|
"duration": 60000
|
|
}];
|
|
|
|
sendMessages(data);
|
|
}
|
|
}
|
|
function makeSticker() {
|
|
var type = getParameterByName("type");
|
|
if (type === "sticker") {
|
|
var stk = getParameterByName("stk");
|
|
var sid = getParameterByName("sid");
|
|
var pkg = getParameterByName("pkg");
|
|
var size = getParameterByName("size") ?? "mega";
|
|
var pngtype = "";
|
|
if (stk === "anim") {
|
|
pngtype = "/IOS/sticker_animation@2x.png";
|
|
} else {
|
|
pngtype = "/IOS/sticker@2x.png";
|
|
}
|
|
|
|
const data1 = [{
|
|
"type": "flex",
|
|
"altText": "Sticker",
|
|
"contents":
|
|
{
|
|
"type": "carousel",
|
|
"contents": [
|
|
{
|
|
"type": "bubble",
|
|
"size": size,
|
|
"body": {
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "image",
|
|
"url": "https://stickershop.line-scdn.net/stickershop/v1/sticker/85913166/IOS/sticker_animation@2x.png",
|
|
"size": "full",
|
|
"aspectMode": "fit",
|
|
"animated": true,
|
|
"backgroundColor": "#FFFFFF00"
|
|
}
|
|
],
|
|
"paddingAll": "none"
|
|
},
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "https://line.me/S/sticker/12378"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}];
|
|
|
|
const data = [{
|
|
"type": "flex",
|
|
"altText": "Sticker",
|
|
"contents":
|
|
{
|
|
"type": "bubble",
|
|
"size": size,
|
|
"body": {
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "image",
|
|
"url": "https://stickershop.line-scdn.net/stickershop/v1/sticker/" + sid + pngtype,
|
|
"size": "full",
|
|
"aspectMode": "fit",
|
|
"animated": true,
|
|
"backgroundColor": "#FFFFFF00"
|
|
}
|
|
],
|
|
"paddingAll": "none"
|
|
},
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "https://line.me/S/sticker/" + pkg
|
|
}
|
|
}
|
|
}];
|
|
|
|
// const data = [{
|
|
// "type": "template",
|
|
// "altText": "Sticker",
|
|
// "template": {
|
|
// "type": "image_carousel",
|
|
// "columns": [{
|
|
// "imageUrl": "https://stickershop.line-scdn.net/stickershop/v1/sticker/" + sid + pngtype,
|
|
// "action": {
|
|
// "type": "uri",
|
|
// // "uri": "line://shop/sticker/detail/" + pkg
|
|
// "uri": "https://line.me/S/sticker/" + pkg
|
|
// }
|
|
// }]
|
|
// }
|
|
// }];
|
|
|
|
sendMessages(data);
|
|
}
|
|
}
|
|
function meProfile() {
|
|
var type = getParameterByName("type");
|
|
liff.getProfile().then(function (profileData) {
|
|
var statusMessage = profileData.statusMessage;
|
|
if (statusMessage == null) {
|
|
var statusMessage = "";
|
|
}
|
|
if (statusMessage.length > 60) {
|
|
var statusMessage = "Status Message is to long! Max 60 words";
|
|
}
|
|
if (type === "profile") {
|
|
const data = [{
|
|
"type": "template",
|
|
"altText": "Profile " + profileData.displayName,
|
|
"template": {
|
|
"type": "buttons",
|
|
"thumbnailImageUrl": profileData.pictureUrl,
|
|
"imageAspectRatio": "square",
|
|
"imageSize": "cover",
|
|
"title": profileData.displayName,
|
|
"text": statusMessage,
|
|
"actions": [{
|
|
"type": "uri",
|
|
"label": "Me",
|
|
"uri": "https://liff.line.me/1657715144-m4W6lyjL?type=profile"
|
|
}]
|
|
}
|
|
}];
|
|
|
|
sendMessages(data);
|
|
}
|
|
});
|
|
}
|
|
|
|
function makeTest() {
|
|
var type = getParameterByName("type");
|
|
if (type === "test") {
|
|
const data = [{
|
|
"type": "flex",
|
|
"altText": "ㄟ, 我跟你說件事",
|
|
"contents":
|
|
{
|
|
"type": "bubble",
|
|
"size": "mega",
|
|
"hero": {
|
|
"type": "image",
|
|
"url": "https://i.imgur.com/BNF0CiC.png",
|
|
"size": "full",
|
|
"aspectRatio": "20:13",
|
|
"aspectMode": "cover",
|
|
"action": {
|
|
"type": "uri",
|
|
"uri": "https://liff.line.me/1656796140-BaDWXE29?GameId=147&Promotion=36tNMgn&RefAccount=BeH7585"
|
|
}
|
|
},
|
|
"body": {
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "text",
|
|
"text": "剛剛不小心在金爸爸尻到100倍大獎",
|
|
"weight": "bold",
|
|
"size": "md"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "實力不允許我低調",
|
|
"align": "center",
|
|
"weight": "bold"
|
|
}
|
|
]
|
|
},
|
|
"footer": {
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"spacing": "sm",
|
|
"contents": [
|
|
{
|
|
"type": "button",
|
|
"style": "link",
|
|
"height": "sm",
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "點進來一起領獎金",
|
|
"uri": "https://liff.line.me/1656796140-BaDWXE29?GameId=147&Promotion=36tNMgn&RefAccount=BeH7585"
|
|
}
|
|
}
|
|
],
|
|
"flex": 0
|
|
}
|
|
}
|
|
}];
|
|
|
|
sendMessages(data);
|
|
}
|
|
}
|
|
|
|
function makeDouDou() {
|
|
var type = getParameterByName("type");
|
|
if (type === "豆豆") {
|
|
const data = [{
|
|
"type": "flex",
|
|
"altText": "ㄟ, 我跟你說件事",
|
|
"contents":
|
|
{
|
|
"type": "bubble",
|
|
"size": "mega",
|
|
"body": {
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "image",
|
|
"url": "https://i.imgur.com/BNF0CiC.png",
|
|
"size": "full",
|
|
"aspectRatio": "20:13",
|
|
"aspectMode": "cover",
|
|
"animated": false,
|
|
"backgroundColor": "#FFFFFF00"
|
|
}
|
|
],
|
|
"paddingAll": "none"
|
|
},
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "https://i.imgur.com/BNF0CiC.png"
|
|
}
|
|
}
|
|
}];
|
|
|
|
sendMessages(data);
|
|
}
|
|
}
|
|
function makeBW() {
|
|
var type = getParameterByName("type");
|
|
if (type === "柏威") {
|
|
const data = [{
|
|
"type": "flex",
|
|
"altText": "ㄟ, 我跟你說件事",
|
|
"contents":
|
|
{
|
|
"type": "bubble",
|
|
"size": "mega",
|
|
"body": {
|
|
"type": "box",
|
|
"layout": "vertical",
|
|
"contents": [
|
|
{
|
|
"type": "image",
|
|
"url": "https://i.imgur.com/BNF0CiC.png",
|
|
"size": "full",
|
|
"aspectRatio": "20:13",
|
|
"aspectMode": "cover",
|
|
"animated": false,
|
|
"backgroundColor": "#FFFFFF00"
|
|
}
|
|
],
|
|
"paddingAll": "none"
|
|
},
|
|
"action": {
|
|
"type": "uri",
|
|
"label": "action",
|
|
"uri": "https://i.imgur.com/BNF0CiC.png"
|
|
}
|
|
}
|
|
}];
|
|
|
|
sendMessages(data);
|
|
}
|
|
}
|
|
|
|
function sendMessages(data) {
|
|
if (liff.isInClient()) {
|
|
liff.sendMessages(data).then(function () {
|
|
liff.closeWindow();
|
|
}).catch(function (error) {
|
|
console.error(`[Line] textx: ${error}`);
|
|
document.getElementById("error").innerHTML = `[Line] textx: ${error}`;
|
|
});
|
|
} else {
|
|
if (liff.isApiAvailable("shareTargetPicker")) {
|
|
liff.shareTargetPicker(data).then(function (res) {
|
|
liff.closeWindow();
|
|
}).catch(function (error) {
|
|
console.error(`[Line] textx: ${error}`);
|
|
document.getElementById("error").innerHTML = `[Line] textx: ${error}`;
|
|
});
|
|
} else {
|
|
document.getElementById("error").innerHTML = `你的 LINE App 暫時不支援 Share Target Picker`;
|
|
}
|
|
}
|
|
} |