mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add seeds to coins
This commit is contained in:
parent
9881ac0b75
commit
738504ebf8
3
@types/global/index.d.ts
vendored
3
@types/global/index.d.ts
vendored
@ -297,6 +297,9 @@ declare global {
|
||||
downloadVideoDefaultDanmaku: '无' | 'XML' | 'ASS',
|
||||
aria2RpcOption: RpcOption,
|
||||
searchHistory: SearchHistoryItem[],
|
||||
seedsToCoins: boolean,
|
||||
autoSeedsToCoins: boolean,
|
||||
lastSeedsToCoinsDate: number,
|
||||
latestVersionLink: string,
|
||||
currentVersion: string,
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -262,6 +262,7 @@ const settings = {
|
||||
searchHistory: [],
|
||||
seedsToCoins: true,
|
||||
autoSeedsToCoins: true,
|
||||
lastSeedsToCoinsDate: 0,
|
||||
cache: {},
|
||||
}
|
||||
const fixedSettings = {
|
||||
|
||||
@ -262,6 +262,7 @@ const settings = {
|
||||
searchHistory: [],
|
||||
seedsToCoins: true,
|
||||
autoSeedsToCoins: true,
|
||||
lastSeedsToCoinsDate: 0,
|
||||
cache: {},
|
||||
}
|
||||
const fixedSettings = {
|
||||
|
||||
2
min/gui-settings.min.js
vendored
2
min/gui-settings.min.js
vendored
@ -1 +1 @@
|
||||
(()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let c=[];let r=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){r.forEach(t=>t.value=e[t.getAttribute("key")]);c.forEach(t=>t.checked=e[t.getAttribute("key")])}function d(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});r.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function u(){c.forEach(t=>{t.addEventListener("change",()=>{const n=t.getAttribute("key");const i=t.checked;e[n]=i;saveSettings(e)})});r.forEach(t=>{t.addEventListener("change",()=>{const n=t.getAttribute("key");const i=s.getValidator(n).validate(t.value);e[n]=i;t.value=i;saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}}function p(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",`<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.5.95/css/materialdesignicons.min.css">`);document.body.classList.add("round-corner");const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",s);t.applyDropdownOptions();const a=document.querySelector(".widgets-container");const m=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){m.classList.add("show")}else{m.classList.remove("show")}});(new n).setupDom();const y=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");const h=document.querySelector(".gui-settings-icon-panel");h.addEventListener("mouseover",()=>{raiseEvent(h,"be:load");y.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];c=o.filter(e=>e.type==="checkbox");r=o.filter(e=>e.type==="text"&&!e.parentElement.classList.contains("gui-settings-dropdown"));d();f();l();g();u();b();p();new i},{once:true})})()}})();
|
||||
(()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let c=[];let r=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){r.forEach(t=>t.value=e[t.getAttribute("key")]);c.forEach(t=>t.checked=e[t.getAttribute("key")])}function d(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});r.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function u(){c.forEach(t=>{t.addEventListener("change",()=>{const n=t.getAttribute("key");const i=t.checked;e[n]=i;saveSettings(e)})});r.forEach(t=>{t.addEventListener("change",()=>{const n=t.getAttribute("key");const i=s.getValidator(n).validate(t.value);e[n]=i;t.value=i;saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}}function p(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",`<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">`);document.body.classList.add("round-corner");const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",s);t.applyDropdownOptions();const a=document.querySelector(".widgets-container");const m=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){m.classList.add("show")}else{m.classList.remove("show")}});(new n).setupDom();const y=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");const h=document.querySelector(".gui-settings-icon-panel");h.addEventListener("mouseover",()=>{raiseEvent(h,"be:load");y.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];c=o.filter(e=>e.type==="checkbox");r=o.filter(e=>e.type==="text"&&!e.parentElement.classList.contains("gui-settings-dropdown"));d();f();l();g();u();b();p();new i},{once:true})})()}})();
|
||||
2
min/seeds-to-coins.min.js
vendored
2
min/seeds-to-coins.min.js
vendored
@ -1 +1 @@
|
||||
(()=>{return(i,t)=>{const c=`https://api.live.bilibili.com/pay/v1/Exchange/silver2coin`;const e=()=>{};return{widget:{content:``,success:e}}}})();
|
||||
(()=>{return(s,e)=>{const t=`https://api.live.bilibili.com/pay/v1/Exchange/silver2coin`;return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="seeds-to-coins">\n <i class="mdi mdi-24px mdi-seed-outline"></i>\n <span>瓜子换硬币</span>\n </button>`,success:()=>{const s=async()=>{const s=await Ajax.getJsonWithCredentials(t);if(s.code!==0){Toast.info(s.message,"瓜子换硬币",3e3)}else{Toast.success(`${s.message}\n剩余银瓜子:${s.data.silver}`,"瓜子换硬币",3e3)}};const e=dq("#seeds-to-coins");e.addEventListener("click",async()=>{try{e.disabled=true;await s()}finally{e.disabled=false}})}}}}})();
|
||||
@ -138,6 +138,7 @@ export const settings = {
|
||||
searchHistory: [],
|
||||
seedsToCoins: true,
|
||||
autoSeedsToCoins: true,
|
||||
lastSeedsToCoinsDate: 0,
|
||||
cache: {},
|
||||
}
|
||||
const fixedSettings = {
|
||||
|
||||
@ -127,7 +127,7 @@ function setDisplayNames () {
|
||||
|
||||
(async () => {
|
||||
resources.applyStyle('guiSettingsStyle')
|
||||
document.body.insertAdjacentHTML('afterbegin', `<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.5.95/css/materialdesignicons.min.css">`)
|
||||
document.body.insertAdjacentHTML('afterbegin', `<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">`)
|
||||
document.body.classList.add('round-corner')
|
||||
|
||||
const isIframe = document.body && unsafeWindow.parent.window !== unsafeWindow
|
||||
|
||||
@ -1,11 +1,39 @@
|
||||
const api = `https://api.live.bilibili.com/pay/v1/Exchange/silver2coin`
|
||||
const seedsToCoins = () => {
|
||||
|
||||
}
|
||||
|
||||
export default {
|
||||
widget: {
|
||||
content: /*html*/``,
|
||||
success: seedsToCoins
|
||||
content: /*html*/`
|
||||
<button
|
||||
class="gui-settings-flat-button"
|
||||
id="seeds-to-coins">
|
||||
<i class="mdi mdi-24px mdi-seed-outline"></i>
|
||||
<span>瓜子换硬币</span>
|
||||
</button>`,
|
||||
success: () => {
|
||||
const exchange = async () => {
|
||||
const json = await Ajax.getJsonWithCredentials(api) as {
|
||||
code: number
|
||||
message: string
|
||||
data: {
|
||||
gold: string
|
||||
silver: string
|
||||
coin: number
|
||||
}
|
||||
}
|
||||
if (json.code !== 0) {
|
||||
Toast.info(json.message, '瓜子换硬币', 3000)
|
||||
} else {
|
||||
Toast.success(`${json.message}\n剩余银瓜子:${json.data.silver}`, '瓜子换硬币', 3000)
|
||||
}
|
||||
}
|
||||
const button = dq('#seeds-to-coins') as HTMLButtonElement
|
||||
button.addEventListener('click', async () => {
|
||||
try {
|
||||
button.disabled = true
|
||||
await exchange()
|
||||
} finally {
|
||||
button.disabled = false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user