diff --git a/go.mod b/go.mod index 2630caceec..9daa90e79b 100644 --- a/go.mod +++ b/go.mod @@ -5,11 +5,11 @@ go 1.21 require ( github.com/go-ini/ini v1.67.0 github.com/mattn/go-colorable v0.1.13 - golang.org/x/net v0.20.0 + golang.org/x/net v0.21.0 ) require ( github.com/mattn/go-isatty v0.0.16 // indirect github.com/stretchr/testify v1.7.1 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/sys v0.17.0 // indirect ) diff --git a/go.sum b/go.sum index 8557a40878..4b75f3c63d 100644 --- a/go.sum +++ b/go.sum @@ -11,11 +11,11 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/jsHelper/spicetifyWrapper.js b/jsHelper/spicetifyWrapper.js index 80d0a0adc9..609fb2f268 100644 --- a/jsHelper/spicetifyWrapper.js +++ b/jsHelper/spicetifyWrapper.js @@ -1550,7 +1550,7 @@ Spicetify.ContextMenuV2 = (() => { })(); Spicetify.Menu = (() => { - const shouldAdd = (_, trigger, target) => trigger === "click" && target.parentElement.classList.contains("main-topBar-topbarContentRight"); + const shouldAdd = (_, trigger, target) => trigger === "click" && target.closest(".main-topBar-container"); class Item extends Spicetify.ContextMenuV2.Item { constructor(children, isEnabled, onClick, leadingIcon) { diff --git a/src/preprocess/preprocess.go b/src/preprocess/preprocess.go index 4bbdc8a270..a24d6acf75 100644 --- a/src/preprocess/preprocess.go +++ b/src/preprocess/preprocess.go @@ -365,14 +365,26 @@ func exposeAPIs_main(input string) string { // Menu hook utils.Replace(&input, `("Menu".+?children:)([\w$][\w$\d]*)`, `${1}[Spicetify.ContextMenuV2.renderItems(),${2}].flat()`) - croppedInput := utils.FindFirstMatch(input, `.*value:"contextmenu"`)[0] - - react := utils.FindLastMatch(croppedInput, `([\w_$]+)\.useRef`)[1] - menu := utils.FindLastMatch(croppedInput, `menu:([\w_$]+)`)[1] - trigger := utils.FindLastMatch(croppedInput, `trigger:([\w_$]+)`)[1] - target := utils.FindLastMatch(croppedInput, `triggerRef:([\w_$]+)`)[1] + croppedInput := utils.FindFirstMatch(input, `"context-menu".*value:"contextmenu"`)[0] + + react := utils.FindFirstMatch(croppedInput, `([\w_$]+)\.useRef`)[1] + var menu string + var trigger string + var target string + + menuCandidates := utils.FindMatch(croppedInput, `menu:([\w_$]+)`) + if len(menuCandidates) == 0 { + // v1.2.13 fix + menu = utils.FindFirstMatch(croppedInput, `([\w_$]+)=[\w_$]+\.menu,`)[1] + trigger = utils.FindFirstMatch(croppedInput, `([\w_$]+)=[\w_$]+\.trigger,`)[1] + target = utils.FindFirstMatch(croppedInput, `([\w_$]+)=[\w_$]+\.triggerRef,`)[1] + } else { + menu = menuCandidates[0][1] + trigger = utils.FindFirstMatch(croppedInput, `trigger:([\w_$]+)`)[1] + target = utils.FindFirstMatch(croppedInput, `triggerRef:([\w_$]+)`)[1] + } - utils.Replace(&input, `\(0,([\w_$]+)\.jsx\)\([\w_$]+\.[\w_$]+,\{value:"contextmenu"[^\}]+\}\)\}\)`, `${1}.jsx((Spicetify.ContextMenuV2._context||(Spicetify.ContextMenuV2._context=`+react+`.createContext(null))).Provider,{value:{props:`+menu+`?.props,trigger:`+trigger+`,target:`+target+`},children:${0}})`) + utils.Replace(&input, `\(0,([\w_$]+)\.jsx\)\([\w_$]+\.[\w_$]+,\{value:"contextmenu"[^\}]+\}\)\}\)`, `(0,${1}.jsx)((Spicetify.ContextMenuV2._context||(Spicetify.ContextMenuV2._context=`+react+`.createContext(null))).Provider,{value:{props:`+menu+`?.props,trigger:`+trigger+`,target:`+target+`},children:${0}})`) return input }