-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from CreatorsDAO/main
update pages
- Loading branch information
Showing
18 changed files
with
720 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
out/ | ||
build/ | ||
dist/ | ||
|
||
# plasmo | ||
.plasmo | ||
|
||
# typescript | ||
.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @type {import('prettier').Options} | ||
*/ | ||
export default { | ||
printWidth: 80, | ||
tabWidth: 2, | ||
useTabs: false, | ||
semi: false, | ||
singleQuote: false, | ||
trailingComma: "none", | ||
bracketSpacing: true, | ||
bracketSameLine: true, | ||
plugins: ["@ianvs/prettier-plugin-sort-imports"], | ||
importOrder: [ | ||
"<BUILTIN_MODULES>", // Node.js built-in modules | ||
"<THIRD_PARTY_MODULES>", // Imports not matched by other special words or groups. | ||
"", // Empty line | ||
"^@plasmo/(.*)$", | ||
"", | ||
"^@plasmohq/(.*)$", | ||
"", | ||
"^~(.*)$", | ||
"", | ||
"^[./]" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Galxe demo getting started | ||
|
||
First: | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
then run the development server: | ||
|
||
``` | ||
pnpm de | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "galxe-demo", | ||
"displayName": "Galxe demo", | ||
"version": "0.0.1", | ||
"description": "706 CreatorsDAO plasmo co learn", | ||
"author": "birch", | ||
"scripts": { | ||
"dev": "plasmo dev", | ||
"build": "plasmo build", | ||
"package": "plasmo package" | ||
}, | ||
"dependencies": { | ||
"@plasmohq/messaging": "^0.6.2", | ||
"@plasmohq/storage": "^1.11.0", | ||
"plasmo": "0.88.0", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@ianvs/prettier-plugin-sort-imports": "4.1.1", | ||
"@types/chrome": "0.0.258", | ||
"@types/node": "20.11.5", | ||
"@types/react": "18.2.48", | ||
"@types/react-dom": "18.2.18", | ||
"autoprefixer": "^10.4.19", | ||
"postcss": "^8.4.39", | ||
"prettier": "3.2.4", | ||
"tailwindcss": "^3.4.6", | ||
"typescript": "5.3.3" | ||
}, | ||
"manifest": { | ||
"host_permissions": [ | ||
"https://*/*" | ||
], | ||
"permissions": [ | ||
"scripting" | ||
] | ||
}, | ||
"compilerOptions": { | ||
"paths": { | ||
"~*": [ | ||
"./src/*" | ||
] | ||
}, | ||
"baseUrl": "." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* @type {import('postcss').ProcessOptions} | ||
*/ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import "@plasmohq/messaging/background" | ||
|
||
import { startHub } from "@plasmohq/messaging/pub-sub" | ||
|
||
startHub() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import type { PlasmoMessaging } from "@plasmohq/messaging" | ||
|
||
export type RequestBody = { | ||
action: string | ||
} | ||
|
||
|
||
const handler: PlasmoMessaging.MessageHandler = async (req) => { | ||
// 查询当前的活动tab | ||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { | ||
// 实例化活动tab | ||
const activeTab = tabs[0]; | ||
// 检查URL是否匹配 | ||
if (activeTab && activeTab.url && activeTab.url.includes('https://app.galxe.com/quest/')) { | ||
if (req.body.action && req.body.action === "start") { | ||
// 执行脚本 | ||
chrome.scripting.executeScript({ | ||
target: { tabId: activeTab.id }, | ||
func: executeCode | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
export default handler | ||
|
||
function executeCode() { | ||
console.log("开始执行..."); | ||
|
||
const elementsToClick = document.querySelectorAll( | ||
'div[data-state="closed"] .cursor-pointer' | ||
), | ||
refreshButtonClass = | ||
'button[data-state="closed"] .ml-4.flex.gap-4.items-center', | ||
waitForClass = 'svg[data-state="closed"] .ml-4.flex.gap-4.items-center', | ||
successIconClass = '.text-size-14.font-bold', | ||
claimButtonSelector = 'button.inline-flex.bg-primary:not([disabled])' | ||
|
||
function clickElement(element) { | ||
const event = new MouseEvent('click', { | ||
view: window, | ||
bubbles: true, | ||
cancelable: true, | ||
}); | ||
element.dispatchEvent(event); | ||
} | ||
|
||
|
||
function checkClaimButton() { | ||
const claimButton = document.querySelector(claimButtonSelector); | ||
if (claimButton && claimButton.textContent.trim() !== 'Explore Now') { | ||
clickElement(claimButton); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function checkConditionsAndRetry() { | ||
const waitForElements = document.querySelectorAll(waitForClass), | ||
successIcons = document.querySelectorAll(successIconClass); | ||
if (waitForElements.length > 0 || successIcons.length !== elementsToClick.length) { | ||
setTimeout(processElements, 60000); | ||
} else { | ||
checkClaimButton(); | ||
} | ||
} | ||
|
||
function processElements() { | ||
if (!checkClaimButton()) { | ||
elementsToClick.forEach((element) => { | ||
if (element.textContent.trim() !== 'Explore Now') { | ||
clickElement(element); | ||
} | ||
}); | ||
setTimeout(() => { | ||
const refreshButtons = document.querySelectorAll(refreshButtonClass); | ||
refreshButtons.forEach(clickElement); | ||
setTimeout(checkConditionsAndRetry, 2000); | ||
}, 2000); | ||
} | ||
} | ||
|
||
processElements(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import "./styles/tailwind.css" | ||
|
||
import { sendToBackground } from "@plasmohq/messaging" | ||
|
||
const handle = async () => { | ||
await sendToBackground({ | ||
name: "galxe", | ||
body: { | ||
action: "start" | ||
} | ||
}) | ||
} | ||
|
||
export default function IndexPopup() { | ||
return ( | ||
<div | ||
className="h-40 w-72 relative flex items-center justify-center" | ||
style={{ | ||
backgroundImage: | ||
"radial-gradient(circle at bottom center, hsl(0 0% 12.9%), hsl(0 0% 2%)" | ||
}}> | ||
<button | ||
onClick={handle} | ||
className="rounded-2xl border-2 border-dashed border-black bg-white px-3 py-1 font-semibold uppercase text-black transition-all duration-300 hover:translate-x-[-4px] hover:translate-y-[-4px] hover:rounded-md hover:shadow-[4px_4px_0px_black] active:translate-x-[0px] active:translate-y-[0px] active:rounded-2xl active:shadow-none"> | ||
start | ||
</button> | ||
<div className="absolute bottom-4 flex items-center text-white"> | ||
<span>Built by </span> | ||
<a | ||
href="https://twitter.com/shadcn" | ||
target="_blank" | ||
rel="noreferrer" | ||
className="font-medium underline underline-offset-4"> | ||
CreatorsDAO | ||
</a> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
mode: "jit", | ||
content: ["./**/*.tsx"], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
} | ||
|
Oops, something went wrong.