|
@@ -714,13 +714,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);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -765,8 +767,8 @@ function initParseCard() {
|
|
|
let inited = false
|
|
|
// 初始化
|
|
|
export function init() {
|
|
|
- if(inited){
|
|
|
- return
|
|
|
+ if (inited) {
|
|
|
+ return
|
|
|
}
|
|
|
inited = true
|
|
|
console.log('init')
|
|
@@ -785,6 +787,7 @@ export function init() {
|
|
|
appendPopupPage();
|
|
|
|
|
|
onBodyClick();
|
|
|
+ initBuyNFT()
|
|
|
|
|
|
getChromeStorage("popupShowPublishDialog", (res) => {
|
|
|
console.log("popupShowPublishDialog", res);
|
|
@@ -1178,6 +1181,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'
|
|
@@ -1188,11 +1213,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;}
|
|
@@ -1221,7 +1246,8 @@ export const appendPopupPage = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export const showPopupPage = (path = '') => {
|
|
|
+export const showPopupPage = (params) => {
|
|
|
+ let { path = '' } = params;
|
|
|
let iframe = document.getElementById('de-extension-popup');
|
|
|
if (iframe) {
|
|
|
iframe.src = chrome.runtime.getURL('/iframe/popup.html') + `#${path}`;
|