2022-12-13 12:19:27 +08:00
window . onload = function ( _0xe315c8 ) {
liff
. init ({
liffId : '1657715144-m4W6lyjL' , // Use own liffId
})
. then (() => {
if ( ! liff . isLoggedIn ()) {
2022-12-29 10:53:27 +08:00
liff . login ({ redirectUri : location . href });
2022-12-13 12:19:27 +08:00
} else {
getP ();
}
});
};
function getP () {
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" ,
2022-12-13 12:24:21 +08:00
"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)" )
2022-12-13 12:19:27 +08:00
}];
sendMessages ( data );
});
document . getElementById ( "videox" ). addEventListener ( "click" , function () {
const data = [{
"type" : "text" ,
2022-12-13 12:24:21 +08:00
"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" )
2022-12-13 12:19:27 +08:00
}];
sendMessages ( data );
});
document . getElementById ( "audiox" ). addEventListener ( "click" , function () {
const data = [{
"type" : "text" ,
2022-12-13 12:24:21 +08:00
"text" : ( "https://liff.line.me/1657715144-m4W6lyjL?type=audio&link=https://platelets.fun/public/sounds/music.mp3" )
2022-12-13 12:19:27 +08:00
}];
sendMessages ( data );
});
document . getElementById ( "stickerx" ). addEventListener ( "click" , function () {
const data = [{
"type" : "text" ,
2022-12-13 12:24:21 +08:00
"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" )
2022-12-13 12:19:27 +08:00
}];
sendMessages ( data );
});
} else {
2022-12-29 10:53:27 +08:00
document . body . innerHTML = "" ;
2022-12-13 12:19:27 +08:00
makeText ();
makeImage ();
makeVideo ();
makeAudio ();
makeSticker ();
meProfile ();
2022-12-29 10:53:27 +08:00
// makeTest();
// makeDouDou();
makeBW ();
2022-12-13 12:19:27 +08:00
}
}
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" );
2022-12-29 10:53:27 +08:00
var size = getParameterByName ( "size" ) ?? "mega" ;
2022-12-13 12:19:27 +08:00
var pngtype = "" ;
if ( stk === "anim" ) {
pngtype = "/IOS/sticker_animation@2x.png" ;
} else {
pngtype = "/IOS/sticker@2x.png" ;
}
2022-12-29 10:53:27 +08:00
const data1 = [{
"type" : "flex" ,
2022-12-13 12:19:27 +08:00
"altText" : "Sticker" ,
2022-12-29 10:53:27 +08:00
"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" : "cover" ,
"animated" : true ,
"backgroundColor" : "#FFFFFF00"
}
],
"paddingAll" : "none"
},
"action" : {
"type" : "uri" ,
"label" : "action" ,
"uri" : "https://line.me/S/sticker/12378"
}
2022-12-13 12:19:27 +08:00
}
2022-12-29 10:53:27 +08:00
]
2022-12-13 12:19:27 +08:00
}
}];
2022-12-29 10:53:27 +08:00
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" : "cover" ,
"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
// }
// }]
// }
// }];
2022-12-13 12:19:27 +08:00
sendMessages ( data );
}
}
function meProfile () {
var type = getParameterByName ( "type" );
2022-12-29 10:53:27 +08:00
liff . getProfile (). then ( function ( profileData ) {
var statusMessage = profileData . statusMessage ;
2022-12-13 12:19:27 +08:00
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" ,
2022-12-29 10:53:27 +08:00
"altText" : "Profile " + profileData . displayName ,
2022-12-13 12:19:27 +08:00
"template" : {
"type" : "buttons" ,
2022-12-29 10:53:27 +08:00
"thumbnailImageUrl" : profileData . pictureUrl ,
2022-12-13 12:19:27 +08:00
"imageAspectRatio" : "square" ,
"imageSize" : "cover" ,
2022-12-29 10:53:27 +08:00
"title" : profileData . displayName ,
2022-12-13 12:19:27 +08:00
"text" : statusMessage ,
"actions" : [{
"type" : "uri" ,
"label" : "Me" ,
2022-12-13 12:24:21 +08:00
"uri" : "https://liff.line.me/1657715144-m4W6lyjL?type=profile"
2022-12-13 12:19:27 +08:00
}]
}
}];
sendMessages ( data );
}
});
}
2022-12-29 10:53:27 +08:00
function makeTest () {
var type = getParameterByName ( "type" );
if ( type === "test" ) {
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 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 );
}
}
2022-12-13 12:19:27 +08:00
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` ;
}
}
}