|
@@ -725,13 +725,15 @@ export function initExecuteScript(changes) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const createIframe = ({ url, tweet_Id }, callback) => {
|
|
|
+const createNFTIframe = ({ url, id }, callback) => {
|
|
|
let iframe = document.createElement('iframe')
|
|
|
- iframe.id = `tweetId${tweet_Id}`
|
|
|
+ iframe.id = id
|
|
|
iframe.src = url
|
|
|
+ iframe.style.cssText = 'border:medium none; width:100%; height:100%; z-index:100; position: fixed; top:0;left:0; display:none;';
|
|
|
iframe.onload = () => {
|
|
|
- callback()
|
|
|
+ callback && callback()
|
|
|
}
|
|
|
+ document.body.appendChild(iframe);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -776,8 +778,8 @@ function initParseCard() {
|
|
|
let inited = false
|
|
|
// 初始化
|
|
|
export function init() {
|
|
|
- if(inited){
|
|
|
- return
|
|
|
+ if (inited) {
|
|
|
+ return
|
|
|
}
|
|
|
inited = true
|
|
|
console.log('init')
|
|
@@ -793,6 +795,7 @@ export function init() {
|
|
|
showNFTCard()
|
|
|
renderDom();
|
|
|
checkTwitterTaskState();
|
|
|
+ initBuyNFT()
|
|
|
|
|
|
getChromeStorage("popupShowPublishDialog", (res) => {
|
|
|
console.log("popupShowPublishDialog", res);
|
|
@@ -1186,6 +1189,28 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+export const hideBuyNFT = () => {
|
|
|
+ let iframe = document.querySelector('#nftProjectId')
|
|
|
+ iframe.style.display = 'none'
|
|
|
+}
|
|
|
+
|
|
|
+export const showBuyNFT = ({ nft_project_Id }) => {
|
|
|
+ if (!nft_project_Id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let iframe = document.querySelector('#nftProjectId')
|
|
|
+ if(!iframe.src.includes(nft_project_Id)){
|
|
|
+ iframe.src = chrome.runtime.getURL(`/iframe/buy-nft.html?nftProjectId=${nft_project_Id}`)
|
|
|
+ }
|
|
|
+ iframe.style.display = 'block'
|
|
|
+}
|
|
|
+
|
|
|
+const initBuyNFT = () => {
|
|
|
+ let url = chrome.runtime.getURL(`/iframe/buy-nft.html`)
|
|
|
+ let id = `nftProjectId`
|
|
|
+ createNFTIframe({ url, id })
|
|
|
+}
|
|
|
+
|
|
|
export const showNFTCard = () => {
|
|
|
let urlInfo = new URL(window.location.href)
|
|
|
let isTwitter = urlInfo.hostname === 'twitter.com'
|
|
@@ -1196,11 +1221,11 @@ export const showNFTCard = () => {
|
|
|
let where = isTwitter && userElem && tabIndex;
|
|
|
if (where) {
|
|
|
let iframe = document.createElement('iframe');
|
|
|
- iframe.src = chrome.runtime.getURL(`/iframe/nft-card.html?pathname=${encodeURIComponent(urlInfo.pathname)}`)
|
|
|
- iframe.style.cssText = 'border:medium none; width:100%; height:297px;';
|
|
|
+ iframe.src = chrome.runtime.getURL(`/iframe/nft-card.html?pathname=${encodeURIComponent(urlInfo.pathname)}`)
|
|
|
+ iframe.style.cssText = 'border:medium none; width:100%; height:297px;';
|
|
|
let nftElement = document.createElement('div');
|
|
|
- nftElement.id = 'de-nft-node';
|
|
|
- nftElement.innerHTML = `
|
|
|
+ nftElement.id = 'de-nft-node';
|
|
|
+ nftElement.innerHTML = `
|
|
|
${iframe.outerHTML}
|
|
|
<style>
|
|
|
#de-nft-node {height:297px; margin-bottom:17px; display:none;}
|