From 14a39b4ef13c0ca806c609d5cb8cf8c66e51006a Mon Sep 17 00:00:00 2001 From: Bergbok <66174189+Bergbok@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:53:28 +0200 Subject: [PATCH] Revert auto-skip-tracks-by-duration workflow to initial state Publish to dist branch again instead of folder within main branch --- .../auto-skip-tracks-by-duration.yml | 26 +++++++++---------- .../dist/auto-skip-tracks-by-duration.js | 1 - 2 files changed, 13 insertions(+), 14 deletions(-) delete mode 100644 Extensions/auto-skip-tracks-by-duration/dist/auto-skip-tracks-by-duration.js diff --git a/.github/workflows/auto-skip-tracks-by-duration.yml b/.github/workflows/auto-skip-tracks-by-duration.yml index 97bd7ef..54882d3 100644 --- a/.github/workflows/auto-skip-tracks-by-duration.yml +++ b/.github/workflows/auto-skip-tracks-by-duration.yml @@ -1,7 +1,6 @@ name: Publish auto-skip-tracks-by-duration on: - workflow_dispatch: push: branches: ['main'] paths: ['Extensions/auto-skip-tracks-by-duration/**'] @@ -27,18 +26,19 @@ jobs: working-directory: Extensions/auto-skip-tracks-by-duration run: npm ci - - name: Remove existing dist folder - run: rm -rf dist - - name: Build run: npm run build-local - - - name: Commit and push changes - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add -A dist - git commit -m "Publish auto-skip-tracks-by-duration" - git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git + + - name: Copy README + run: cp README.md ./dist/README.md + + - name: Copy preview + run: cp README.md ./dist/preview.png + + - name: Publish to seperate branch + uses: s0/git-publish-subdir-action@develop env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: self + BRANCH: dist/auto-skip-tracks-by-duration + FOLDER: ./Extensions/auto-skip-tracks-by-duration/dist + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Extensions/auto-skip-tracks-by-duration/dist/auto-skip-tracks-by-duration.js b/Extensions/auto-skip-tracks-by-duration/dist/auto-skip-tracks-by-duration.js deleted file mode 100644 index 6669649..0000000 --- a/Extensions/auto-skip-tracks-by-duration/dist/auto-skip-tracks-by-duration.js +++ /dev/null @@ -1 +0,0 @@ -!async function(){for(;!Spicetify.React||!Spicetify.ReactDOM;)await new Promise(e=>setTimeout(e,10));var r,o,d,c,u,p,e,t,i,l,n,a,s;r=Object.create,o=Object.defineProperty,d=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,u=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,i=(e=(e,t)=>function(){return t||(0,e[c(e)[0]])((t={exports:{}}).exports,t),t.exports})({"external-global-plugin:react-dom"(e,t){t.exports=Spicetify.ReactDOM}}),l=(t=(e,t,i)=>{i=null!=e?r(u(e)):{};var n=!t&&e&&e.__esModule?i:o(i,"default",{value:e,enumerable:!0}),a=e,s=void 0,l=void 0;if(a&&"object"==typeof a||"function"==typeof a)for(let e of c(a))p.call(n,e)||e===s||o(n,e,{get:()=>a[e],enumerable:!(l=d(a,e))||l.enumerable});return n})(e({"external-global-plugin:react"(e,t){t.exports=Spicetify.React}})()),n=t(i()),a=class{constructor(e,t,i={}){this.name=e,this.settingsId=t,this.initialSettingsFields=i,this.settingsFields=this.initialSettingsFields,this.setRerender=null,this.pushSettings=async()=>{for(Object.entries(this.settingsFields).forEach(([e,t])=>{"button"!==t.type&&void 0===this.getFieldValue(e)&&this.setFieldValue(e,t.defaultValue)});!Spicetify?.Platform?.History?.listen;)await new Promise(e=>setTimeout(e,100));this.stopHistoryListener&&this.stopHistoryListener(),this.stopHistoryListener=Spicetify.Platform.History.listen(e=>{"/preferences"===e.pathname&&this.render()}),"/preferences"===Spicetify.Platform.History.location.pathname&&await this.render()},this.rerender=()=>{this.setRerender&&this.setRerender(Math.random())},this.render=async()=>{for(;!document.getElementById("desktop.settings.selectLanguage");){if("/preferences"!==Spicetify.Platform.History.location.pathname)return;await new Promise(e=>setTimeout(e,100))}var e=document.querySelector(".main-view-container__scroll-node-child main div");if(!e)return console.error("[spcr-settings] settings container not found");let t=Array.from(e.children).find(e=>e.id===this.settingsId);t?console.log(t):((t=document.createElement("div")).id=this.settingsId,e.appendChild(t)),n.default.render(l.default.createElement(this.FieldsContainer,null),t)},this.addButton=(e,t,i,n,a)=>{this.settingsFields[e]={type:"button",description:t,value:i,events:{onClick:n,...a}}},this.addInput=(e,t,i,n,a,s)=>{this.settingsFields[e]={type:"input",description:t,defaultValue:i,inputType:a,events:{onChange:n,...s}}},this.addHidden=(e,t)=>{this.settingsFields[e]={type:"hidden",defaultValue:t}},this.addToggle=(e,t,i,n,a)=>{this.settingsFields[e]={type:"toggle",description:t,defaultValue:i,events:{onChange:n,...a}}},this.addDropDown=(e,t,i,n,a,s)=>{this.settingsFields[e]={type:"dropdown",description:t,defaultValue:i[n],options:i,events:{onSelect:a,...s}}},this.getFieldValue=e=>JSON.parse(Spicetify.LocalStorage.get(this.settingsId+"."+e)||"{}")?.value,this.setFieldValue=(e,t)=>{Spicetify.LocalStorage.set(this.settingsId+"."+e,JSON.stringify({value:t}))},this.FieldsContainer=()=>{var[e,t]=(0,l.useState)(0);return this.setRerender=t,l.default.createElement("div",{className:"x-settings-section",key:e},l.default.createElement("h2",{className:"TypeElement-cello-textBase-type"},this.name),Object.entries(this.settingsFields).map(([e,t])=>l.default.createElement(this.Field,{nameId:e,field:t})))},this.Field=i=>{var e=this.settingsId+"."+i.nameId;let t;if(t="button"===i.field.type?i.field.value:this.getFieldValue(i.nameId),"hidden"===i.field.type)return l.default.createElement(l.default.Fragment,null);const[n,a]=(0,l.useState)(t),s=e=>{void 0!==e&&(a(e),this.setFieldValue(i.nameId,e))};return l.default.createElement("div",{className:"x-settings-row"},l.default.createElement("div",{className:"x-settings-firstColumn"},l.default.createElement("label",{className:"TypeElement-viola-textSubdued-type",htmlFor:e},i.field.description||"")),l.default.createElement("div",{className:"x-settings-secondColumn"},"input"===i.field.type?l.default.createElement("input",{className:"x-settings-input",id:e,dir:"ltr",value:n,type:i.field.inputType||"text",...i.field.events,onChange:e=>{s(e.currentTarget.value);var t=i.field.events?.onChange;t&&t(e)}}):"button"===i.field.type?l.default.createElement("span",null,l.default.createElement("button",{id:e,className:"Button-sm-buttonSecondary-isUsingKeyboard-useBrowserDefaultFocusStyle x-settings-button",...i.field.events,onClick:e=>{s();var t=i.field.events?.onClick;t&&t(e)},type:"button"},n)):"toggle"===i.field.type?l.default.createElement("label",{className:"x-settings-secondColumn x-toggle-wrapper"},l.default.createElement("input",{id:e,className:"x-toggle-input",type:"checkbox",checked:n,...i.field.events,onClick:e=>{s(e.currentTarget.checked);var t=i.field.events?.onClick;t&&t(e)}}),l.default.createElement("span",{className:"x-toggle-indicatorWrapper"},l.default.createElement("span",{className:"x-toggle-indicator"}))):"dropdown"===i.field.type?l.default.createElement("select",{className:"main-dropDown-dropDown",id:e,...i.field.events,onChange:e=>{s(i.field.options[e.currentTarget.selectedIndex]);var t=i.field.events?.onChange;t&&t(e)}},i.field.options.map((e,t)=>l.default.createElement("option",{selected:e===n,value:t+1},e))):l.default.createElement(l.default.Fragment,null)))}}},s=async function(){var e,t;for((t=new a("Auto Skip Tracks by Duration Settings","auto-skip-tracks-by-length")).addInput("min-track-length","Minimum track duration (in seconds)","10"),t.addInput("max-track-length","Maximum track duration (in seconds)","720"),t.addToggle("skip-tracks-over-max-length","Skip tracks over maximum length",!0),t.pushSettings();null==(e=null==Spicetify?void 0:Spicetify.Player)||!e.addEventListener;)await new Promise(e=>setTimeout(e,100));Spicetify.Player.addEventListener("songchange",e=>{var t,i,n;null!=(t=null==e?void 0:e.data)&&t.duration&&(t=1e3*parseInt(JSON.parse(Spicetify.LocalStorage.get("auto-skip-tracks-by-length.min-track-length")||"5").value),i=1e3*parseInt(JSON.parse(Spicetify.LocalStorage.get("auto-skip-tracks-by-length.max-track-length")||"720").value),n=JSON.parse(Spicetify.LocalStorage.get("auto-skip-tracks-by-length.skip-tracks-over-max-length")||"false").value,e.data.durationi)&&Spicetify.Player.next()})},(async()=>{await s()})()}(); \ No newline at end of file