Skip to content

Commit

Permalink
feat: 🎸 update share to x link
Browse files Browse the repository at this point in the history
  • Loading branch information
futantan committed Nov 13, 2024
1 parent 896a0f1 commit 27b7c15
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Binary file modified javascript/tokenscript-viewer/src/assets/icon/x-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import { Component, h, Prop } from '@stencil/core';
import { getTgUrl } from '../viewers/util/tgUrl';

const X_POST_URL = "https://x.com/intent/tweet";

function buildTlinkToShareOnTwitter() {
const url = new URL(document.location.href);
// change host to tlink.store/tapp
const newUrl = new URL('tapp', 'https://tlink.store');

url.searchParams.forEach((value, key) => {
newUrl.searchParams.set(key, value);
});

// add tokenId to the new url
const tokenIdMatch = url.hash.match(/tokenId=([^&]+)/);
if (tokenIdMatch) {
newUrl.searchParams.set('tokenId', tokenIdMatch[1]);
}

newUrl.hash = url.hash;

return newUrl.toString();
}

function getXPostUrl(){
return `${X_POST_URL}?text=${encodeURIComponent(document.location.href)+ " #SmartLayer #Tapps"}&related=SmartLayer`;
return `${X_POST_URL}?text=${encodeURIComponent(buildTlinkToShareOnTwitter()) + ' #SmartLayer #Tapps'}&related=SmartLayer`;
}

@Component({
Expand All @@ -25,7 +44,7 @@ export class XShareButton {
title="Share on Telegram"
>
<img alt="Share to X.com" title="Share to X.com"
src="/assets/icon/x-icon.png" style={{ width: '100%', height: '100%' }} />
src="/assets/icon/x-icon.png" style={{ width: '100%', height: '100%', borderRadius: '9999px' }} />
</a>
</div>
);
Expand Down

0 comments on commit 27b7c15

Please sign in to comment.