Skip to content

Commit

Permalink
調整 pt 取得來源
Browse files Browse the repository at this point in the history
  • Loading branch information
joe committed Dec 23, 2024
1 parent 5549684 commit 7a5298c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 93 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,4 +785,11 @@ ChatGPT 雖然很厲害,但也有它的極限,所以我們要加強自己的
送審日期:2024/12/19
通過日期:2024/12/21

- 增加 AD 輪撥功能
- 增加 AD 輪撥功能

### 1.4.1 版

送審日期:2024/12/21
通過日期:2024/12/23

- 調整 pt 取得來源
141 changes: 50 additions & 91 deletions js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,57 @@ const supportClaude = window.location.href.includes("claude.ai");
const userLanguage = navigator.language || chrome.i18n.getUILanguage();
const isTW = userLanguage?.includes("zh-TW");

const adLinks = [
`<a
id="ig-button"
href="https://www.instagram.com/dearfine_metal"
target="_blank"
>
${isTW ? '緻金工 DearFine' : 'DearFine'}
</a>
`,
`<a href="https://www.buymeacoffee.com/Joe.lin" target="_blank">
<img style="scale: 0.9;" src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=Joe.lin&button_colour=FFDD00&font_colour=000000&font_family=Inter&outline_colour=000000&coffee_colour=ffffff?${new Date().getTime()}" />
</a>
`,
`<a
id="threads-button"
href="https://www.threads.net/@dearfine_metal"
target="_blank"
>
${isTW ? '緻金工 DearFine' : 'DearFine'}
</a>
`,
`
<a
id="pinkoi-button"
href="https://www.pinkoi.com/store/dearfine"
target="_blank"
>
${isTW ? '緻金工 DearFine' : 'DearFine'}
</a>
`,
`
<a
id="pinkoi-button"
href="https://www.pinkoi.com/product/yqc8ddKe"
target="_blank"
>
${isTW ? '緻金工 💍 🌼 🆕' : 'DearFine 💍 🌼 🆕'}
</a>
`,
`
<a
id="pinkoi-button"
href="https://www.pinkoi.com/product/4CfgRbAm"
target="_blank"
>
${isTW ? '緻金工 🌼 ✨' : 'DearFine 🌼 ✨'}
</a>
`,
`<a
id="pinkoi-button"
href="https://www.pinkoi.com/product/dqAqgjxF"
target="_blank"
>
${isTW ? '緻金工 🦋 ✨' : 'DearFine 🦋 ✨'}
</a>`,
`<a
id="pinkoi-button"
href="https://www.pinkoi.com/product/g8d7p233"
target="_blank"
>
${isTW ? '緻金工 💍 ✨' : 'DearFine 💍 ✨'}
</a>
`,
`<a
id="pinkoi-button"
href="https://www.pinkoi.com/product/zL3M89iq"
target="_blank"
>
${isTW ? '緻金工 💍 💍 ✨' : 'DearFine 💍 💍 ✨'}
</a>
`,
const defaultPtItem = `<a href="https://www.buymeacoffee.com/Joe.lin" target="_blank">
<img style="scale: 0.9;" src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=Joe.lin&button_colour=FFDD00&font_colour=000000&font_family=Inter&outline_colour=000000&coffee_colour=ffffff?${new Date().getTime()}" />
</a>
`;

const ptLinks = [
defaultPtItem
]

fetch('https://raw.githubusercontent.com/JiaHongL/chat-prompt-configs/refs/heads/main/prompt-config.json?'+new Date().getTime())
.then(response => {
if (!response?.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response?.json(); // 將 Response 轉換為 JSON 格式
})
.then(data => {
data?.forEach((pt) => {
ptLinks.push(`
<a
id="${pt.id}"
href="${pt.prompt}"
target="_blank"
>
${isTW ? pt.labelTW : pt.labelEN }
</a>
`);
})
})
.then(() => {
getRandomPTLink();
if(ptLinks.length > 1){
setInterval(() => {
getRandomPTLink();
},8000)
}
})
.catch(error => console.error('載入失敗:', error.message));

let preRandomIndex = null;

function getRandomAdLink() {
const randomIndex = Math.floor(Math.random() * adLinks.length);
function getRandomPTLink() {
const randomIndex = Math.floor(Math.random() * ptLinks.length);
if (preRandomIndex === randomIndex) {
return getRandomAdLink();
return getRandomPTLink();
}
document.querySelectorAll('.friend-links-2024-12-19-sun-o-ad').forEach((element) => {
element.innerHTML = adLinks[randomIndex];
document.querySelectorAll('.sun-o-pt-12-25').forEach((element) => {
element.innerHTML = ptLinks[randomIndex];
});
}

setTimeout(() => {
getRandomAdLink();
setInterval(() => {
getRandomAdLink();
},7000)
},200);

const supportChatGPT = !supportGemini && !supportClaude;

if (supportGemini) {
Expand Down Expand Up @@ -1502,7 +1461,7 @@ function findGroupAndIndex(promptId) {
align-items: center;
padding:20px 0px;
}
.footer .friend-links-2024-12-19-sun-o-ad {
.footer .sun-o-pt-12-25 {
position: absolute;
right: 0;
}
Expand Down Expand Up @@ -2020,7 +1979,7 @@ function findGroupAndIndex(promptId) {
<button id="dialog-cancel" class="secondary" tabindex="5">${i18n(
"button_cancel"
)} ( esc )</button>
<div class="friend-links-2024-12-19-sun-o-ad"></div>
<div class="sun-o-pt-12-25"></div>
</div>
</div>
</div>
Expand Down Expand Up @@ -2374,7 +2333,7 @@ function findGroupAndIndex(promptId) {
<button tabindex="100" id="dialog2-cancel" class="secondary">${i18n(
"button_cancel"
)} ( esc ) </button>
<div class="friend-links-2024-12-19-sun-o-ad"></div>
<div class="sun-o-pt-12-25"></div>
</div>
</div>
Expand Down Expand Up @@ -2778,7 +2737,7 @@ function findGroupAndIndex(promptId) {
<button tabindex="1000" id="dialog4-cancel" class="secondary">${i18n(
"button_cancel"
)} ( esc ) </button>
<div class="friend-links-2024-12-19-sun-o-ad"></div>
<div class="sun-o-pt-12-25"></div>
</div>
</div>
Expand Down Expand Up @@ -2835,7 +2794,7 @@ function findGroupAndIndex(promptId) {
<button id="dialog5-cancel" class="secondary">${i18n(
"button_close"
)} ( esc ) </button>
<div class="friend-links-2024-12-19-sun-o-ad"></div>
<div class="sun-o-pt-12-25"></div>
</div>
</div>
Expand Down Expand Up @@ -2923,7 +2882,7 @@ function findGroupAndIndex(promptId) {
<button tabindex="1000" id="dialog6-cancel" class="secondary">${i18n(
"button_cancel"
)} ( esc ) </button>
<div class="friend-links-2024-12-19-sun-o-ad"></div>
<div class="sun-o-pt-12-25"></div>
</div>
</div>
</div>
Expand Down Expand Up @@ -2951,7 +2910,7 @@ function findGroupAndIndex(promptId) {
<button tabindex="100" id="dialog7-cancel" class="secondary">${i18n(
"button_cancel"
)} ( esc ) </button>
<div class="friend-links-2024-12-19-sun-o-ad"></div>
<div class="sun-o-pt-12-25"></div>
</div>
</div>
</div>
Expand All @@ -2969,7 +2928,7 @@ function findGroupAndIndex(promptId) {
<button tabindex="100" id="dialog8-cancel" class="secondary">${i18n(
"button_cancel"
)} ( esc ) </button>
<div class="friend-links-2024-12-19-sun-o-ad"></div>
<div class="sun-o-pt-12-25"></div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "__MSG_extension_name__",
"description": "__MSG_extension_description__",
"author": "Joe",
"version": "1.4.0",
"version": "1.4.1",
"default_locale": "en",
"icons": {
"16": "images/icon/16.png",
Expand Down

0 comments on commit 7a5298c

Please sign in to comment.