Skip to content

Commit

Permalink
Merge pull request #32 from ufodynasty/parameter-fetcher
Browse files Browse the repository at this point in the history
Auto parameter fetcher
  • Loading branch information
nullieee authored Mar 1, 2024
2 parents 0f0a7dc + 03be615 commit 56826b9
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 71 deletions.
111 changes: 51 additions & 60 deletions Init.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
function completeSetup() {
Object.defineProperty(globalThis, 'calcLevelStars', { get: () => {return Bn},set: (val) => {Bn = val}});
Object.defineProperty(globalThis, 'clevels', { get: () => {return Rt},set: (val) => {Rt = val}});
Object.defineProperty(globalThis, 'copyLevel', { get: () => {return Mo},set: (val) => {Mo = val}});
Object.defineProperty(globalThis, 'copyObject', { get: () => {return X},set: (val) => {X = val}});
// Object.defineProperty(globalThis, 'fitText', { get: () => {return Dt},set: (val) => {Dt = val}});
Object.defineProperty(globalThis, 'game', { get: () => {return Tt},set: (val) => {Tt = val}});
Object.defineProperty(globalThis, 'getLevelDownloadState', { get: () => {return qo},set: (val) => {qo = val}});
// Object.defineProperty(globalThis, 'img', { get: () => {return St},set: (val) => {St = val}});
Object.defineProperty(globalThis, 'lang', { get: () => {return Pt},set: (val) => {Pt = val}});
// Object.defineProperty(globalThis, 'langList', { get: () => {return U},set: (val) => {U = val}});
Object.defineProperty(globalThis, 'langSel', { get: () => {return xt},set: (val) => {xt = val}});
Object.defineProperty(globalThis, 'langs', { get: () => {return F},set: (val) => {F = val}});
Object.defineProperty(globalThis, 'levels', { get: () => {return Ht},set: (val) => {Ht = val}});
Object.defineProperty(globalThis, 'lvlHowl', { get: () => {return Qt},set: (val) => {Qt = val}});
Object.defineProperty(globalThis, 'menu', { get: () => {return Bt},set: (val) => {Bt = val}});
Object.defineProperty(globalThis, 'menuMusic', { get: () => {return to},set: (val) => {to = val}});
Object.defineProperty(globalThis, 'musicManager', { get: () => {return cs},set: (val) => {cs = val}}); // This name is wrong
Object.defineProperty(globalThis, 'nav', { get: () => {return c},set: (val) => {c = val}}); // This name is wrong
Object.defineProperty(globalThis, 'newGrabLevelMeta', { get: () => {return H},set: (val) => {H = val}});
Object.defineProperty(globalThis, 'newGrabLevel', { get: () => {return m},set: (val) => {m = val}});
Object.defineProperty(globalThis, 'screen', { get: () => {return He},set: (val) => {He = val}});
Object.defineProperty(globalThis, 'theme', { get: () => {return $},set: (val) => {$ = val}});
Object.defineProperty(globalThis, 'themes', { get: () => {return qe},set: (val) => {qe = val}});
Object.defineProperty(globalThis, 'toLoad', { get: () => {return Ne},set: (val) => {Ne = val}});
Object.defineProperty(globalThis, 'user', { get: () => {return T},set: (val) => {T = val}});
Object.defineProperty(globalThis, 'welcome', { get: () => {return s},set: (val) => {s = val}});
Object.defineProperty(globalThis, 'newGrabUser', { get: () => {return Ut},set: (val) => {Ut = val}});
Object.defineProperty(globalThis, 'drawScreens', { get: () => {return gs},set: (val) => {gs = val}}); // This is wrong
Object.defineProperty(globalThis, 'clickMenu', { get: () => {return fs},set: (val) => {fs = val}}); // This is wrong
Object.defineProperty(globalThis, 'ease', { get: () => {return At},set: (val) => {At = val}});
Object.defineProperty(globalThis, 'editorAction', { get: () => {return kn},set: (val) => {kn = val}});
Object.defineProperty(globalThis, 'executePlay', { get: () => {return en},set: (val) => {en = val}});
Object.defineProperty(globalThis, 'hitbox', { get: () => {return Ft},set: (val) => {Ft = val}});
Object.defineProperty(globalThis, 'loadLevel', { get: () => {return qi},set: (val) => {qi = val}});
// Object.defineProperty(globalThis, 'loadStartScreens', { get: () => {return Cs},set: (val) => {Cs = val}}); // This is wrong
Object.defineProperty(globalThis, 'newSettingsMenu', { get: () => {return Jo},set: (val) => {Jo = val}});
Object.defineProperty(globalThis, 'promptRes', { get: () => {return ki},set: (val) => {ki = val}});
// Object.defineProperty(globalThis, 'prmpt', { get: () => {return Ri},set: (val) => {Ri = val}});
Object.defineProperty(globalThis, 'popupMessage', { get: () => {return Gn},set: (val) => {Gn = val}}); // This is wrong
Object.defineProperty(globalThis, 'prmpting', { get: () => {return g},set: (val) => {g = val}});
Object.defineProperty(globalThis, 'saveGameData', { get: () => {return Qn},set: (val) => {Qn = val}});
Object.defineProperty(globalThis, 'server', { get: () => {return v},set: (val) => {v = val}});
Object.defineProperty(globalThis, 'prmptingString', { get: () => {return Nt},set: (val) => {Nt = val}});
Object.defineProperty(globalThis, 'scrollTimeline', { get: () => {return qn},set: (val) => {qn = val}}); // This is wrong
game.pulseHax = {params: {}};
Object.defineProperty(globalThis, 'calcLevelStars', {get:()=>{ return Bn },set:(val)=>{ Bn =val}});
Object.defineProperty(globalThis, 'clevels', {get:()=>{ return Rt },set:(val)=>{ Rt =val}});
Object.defineProperty(globalThis, 'clickMenu', {get:()=>{ return fs },set:(val)=>{ fs =val}});
Object.defineProperty(globalThis, 'copyLevel', {get:()=>{ return Mo },set:(val)=>{ Mo =val}});
Object.defineProperty(globalThis, 'copyObject', {get:()=>{ return X },set:(val)=>{ X =val}});
Object.defineProperty(globalThis, 'drawScreens', {get:()=>{ return gs },set:(val)=>{ gs =val}});
Object.defineProperty(globalThis, 'ease', {get:()=>{ return At },set:(val)=>{ At =val}});
Object.defineProperty(globalThis, 'editorAction', {get:()=>{ return kn },set:(val)=>{ kn =val}});
Object.defineProperty(globalThis, 'executePlay', {get:()=>{ return en },set:(val)=>{ en =val}});
Object.defineProperty(globalThis, 'fitText', {get:()=>{ return Dt },set:(val)=>{ Dt =val}});
Object.defineProperty(globalThis, 'game', {get:()=>{ return Tt },set:(val)=>{ Tt =val}});
Object.defineProperty(globalThis, 'getLevelDownloadState', {get:()=>{ return qo },set:(val)=>{ qo =val}});
Object.defineProperty(globalThis, 'getObject', {get:()=>{ return te },set:(val)=>{ te =val}});
Object.defineProperty(globalThis, 'hitbox', {get:()=>{ return Ft },set:(val)=>{ Ft =val}});
Object.defineProperty(globalThis, 'img', {get:()=>{ return St },set:(val)=>{ St =val}});
Object.defineProperty(globalThis, 'lang', {get:()=>{ return Pt },set:(val)=>{ Pt =val}});
Object.defineProperty(globalThis, 'langList', {get:()=>{ return U },set:(val)=>{ U =val}});
Object.defineProperty(globalThis, 'langSel', {get:()=>{ return xt },set:(val)=>{ xt =val}});
Object.defineProperty(globalThis, 'langs', {get:()=>{ return F },set:(val)=>{ F =val}});
Object.defineProperty(globalThis, 'levels', {get:()=>{ return Ht },set:(val)=>{ Ht =val}});
Object.defineProperty(globalThis, 'loadLevel', {get:()=>{ return qi },set:(val)=>{ qi =val}});
Object.defineProperty(globalThis, 'loadStartScreens', {get:()=>{ return Cs },set:(val)=>{ Cs =val}});
Object.defineProperty(globalThis, 'lvlHowl', {get:()=>{ return Qt },set:(val)=>{ Qt =val}});
Object.defineProperty(globalThis, 'matrix', {get:()=>{ return zt },set:(val)=>{ zt =val}});
Object.defineProperty(globalThis, 'menu', {get:()=>{ return Bt },set:(val)=>{ Bt =val}});
Object.defineProperty(globalThis, 'menuMusic', {get:()=>{ return to },set:(val)=>{ to =val}});
Object.defineProperty(globalThis, 'musicManager', {get:()=>{ return cs },set:(val)=>{ cs =val}});
Object.defineProperty(globalThis, 'nav', {get:()=>{ return c },set:(val)=>{ c =val}});
Object.defineProperty(globalThis, 'newGrabLevel', {get:()=>{ return m },set:(val)=>{ m =val}});
Object.defineProperty(globalThis, 'newGrabLevelMeta', {get:()=>{ return H },set:(val)=>{ H =val}});
Object.defineProperty(globalThis, 'newGrabUser', {get:()=>{ return Ut },set:(val)=>{ Ut =val}});
Object.defineProperty(globalThis, 'newSettingsMenu', {get:()=>{ return Jo },set:(val)=>{ Jo =val}});
Object.defineProperty(globalThis, 'popupMessage', {get:()=>{ return Gn },set:(val)=>{ Gn =val}});
Object.defineProperty(globalThis, 'prmpt', {get:()=>{ return Ri },set:(val)=>{ Ri =val}});
Object.defineProperty(globalThis, 'prmpting', {get:()=>{ return g },set:(val)=>{ g =val}});
Object.defineProperty(globalThis, 'prmptingString', {get:()=>{ return Nt },set:(val)=>{ Nt =val}});
Object.defineProperty(globalThis, 'promptRes', {get:()=>{ return ki },set:(val)=>{ ki =val}});
Object.defineProperty(globalThis, 'saveGameData', {get:()=>{ return Qn },set:(val)=>{ Qn =val}});
Object.defineProperty(globalThis, 'screen', {get:()=>{ return He },set:(val)=>{ He =val}});
Object.defineProperty(globalThis, 'scrollTimeline', {get:()=>{ return qn },set:(val)=>{ qn =val}});
Object.defineProperty(globalThis, 'server', {get:()=>{ return v },set:(val)=>{ v =val}});
Object.defineProperty(globalThis, 'theme', {get:()=>{ return $ },set:(val)=>{ $ =val}});
Object.defineProperty(globalThis, 'themes', {get:()=>{ return qe },set:(val)=>{ qe =val}});
Object.defineProperty(globalThis, 'toLoad', {get:()=>{ return Ne },set:(val)=>{ Ne =val}});
Object.defineProperty(globalThis, 'user', {get:()=>{ return T },set:(val)=>{ T =val}});
Object.defineProperty(globalThis, 'welcome', {get:()=>{ return s },set:(val)=>{ s =val}});
game.pulseHax = {};
window.dispatchEvent(new CustomEvent('SetupComplete'));
};
eval(`
Expand Down Expand Up @@ -91,9 +93,11 @@ window.addEventListener("SetupComplete", function() {
game.rgbToHex = function(r, g, b) {
return "#" + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);
}
game.pulseHax.params.NSMItem = newSettingsMenu.prototype.draw.toString()[newSettingsMenu.prototype.draw.toString().indexOf(`.type`)-2] === "=" ?
game.pulseHax.params = {
NSMItem: newSettingsMenu.prototype.draw.toString()[newSettingsMenu.prototype.draw.toString().indexOf(`.type`)-2] === "=" ?
newSettingsMenu.prototype.draw.toString()[newSettingsMenu.prototype.draw.toString().indexOf(`.type`)-1] :
newSettingsMenu.prototype.draw.toString()[newSettingsMenu.prototype.draw.toString().indexOf(`.type`)-1] + newSettingsMenu.prototype.draw.toString()[newSettingsMenu.prototype.draw.toString().search(`.type`)-2]
newSettingsMenu.prototype.draw.toString()[newSettingsMenu.prototype.draw.toString().indexOf(`.type`)-1] + newSettingsMenu.prototype.draw.toString()[newSettingsMenu.prototype.draw.toString().search(`.type`)-2],
};
const themeNames = {
theme_addt_gufo: "Gufo's theme",
theme_addt_floopy: "Floopy's theme",
Expand Down Expand Up @@ -269,19 +273,6 @@ window.addEventListener("SetupComplete", function() {
game.menuNSM.pages[0].items[10].event.toString()
.slice(0, -1) + ",game.mods.hidden=false}"
};
newSettingsMenu.prototype.draw = ${
newSettingsMenu.prototype.draw.toString()
.replace(`hue:e.hue,`, `hue:e.hue, after: e.after,`)
.replace(`open}})`, `open; if(!game.pulseHax.dropdownClosed) {
let interval = setInterval(() => {
if(e.animation.height === 0) {
clearInterval(interval);
e.after?.();
}
}, 500)
}; game.pulseHax.dropdownClosed = false}})`)
.replace(`${game.pulseHax.params.NSMItem}.animation.height=0,`, `(${game.pulseHax.params.NSMItem}.animation.height = 0, game.pulseHax.dropdownClosed = false),`)
};
saveGameData = function${
saveGameData.toString()
.replace('{', `{
Expand Down
8 changes: 4 additions & 4 deletions contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ initScript.src = chrome.runtime.getURL(`Init.js`);
initScript.onload = function() {
this.remove();
};
let phDraw = document.createElement('script');
phDraw.src = chrome.runtime.getURL(`editorMenu.js`);
phDraw.onload = function() {
let editorMenu = document.createElement('script');
editorMenu.src = chrome.runtime.getURL(`editorMenu.js`);
editorMenu.onload = function() {
this.remove();
};
(document.documentElement || document.head).append(initScript, phDraw);
(document.documentElement || document.head).append(initScript, editorMenu);

chrome.storage.onChanged.addListener(function(changes, areaName) {
if(areaName === "local" && Object.hasOwn(changes, "CustomTheme")) {
Expand Down
25 changes: 19 additions & 6 deletions editorMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,22 @@ window.addEventListener("SetupComplete", function() {
game.selectBeats = function(condition, options) {
if(condition === "current") {
if(options === "checkCurrent") {
return game.beat.filter((b) => game.timelineTickFor(b[1]) === Math.round(game.timelineTickFor(game.time) / game.snap) * game.snap).map((b) => game.beat.indexOf(b)).length === 0;
};
game.beat.filter((b) => game.timelineTickFor(b[1]) === Math.round(game.timelineTickFor(game.time) / game.snap) * game.snap).map((b) => game.beat.indexOf(b)).forEach((b) => {
return game.beat.filter((b) => {
if(!game.playing) {
return game.timelineTickFor(b[1]) === round(game.timelineTickFor(game.time) / game.snap, 6) * game.snap;
} else {
return game.timelineTickFor(b[1]) <= round(game.timelineTickFor(game.time) / game.snap, 6) * game.snap + game.snap/2 && game.timelineTickFor(b[1]) >= round(game.timelineTickFor(game.time) / game.snap, 6) * game.snap - game.snap/2;
}
}
).map((b) => game.beat.indexOf(b)).length === 0};
game.beat.filter((b) => {
if(!game.playing) {
return game.timelineTickFor(b[1]) === round(game.timelineTickFor(game.time) / game.snap, 6) * game.snap;
} else {
return game.timelineTickFor(b[1]) <= round(game.timelineTickFor(game.time) / game.snap, 6) * game.snap + game.snap/2 && game.timelineTickFor(b[1]) >= round(game.timelineTickFor(game.time) / game.snap, 6) * game.snap - game.snap/2;
}
}
).map((b) => game.beat.indexOf(b)).forEach((b) => {
if(game.selectedBeats.includes(b)) {
game.selectedBeats.splice(game.selectedBeats.indexOf(b), 1)
} else {
Expand Down Expand Up @@ -644,14 +657,14 @@ game.selectBeats = function(condition, options) {
else if(predescescor !== undefined && successor !== undefined) {
// Check for stream end
if(!options.selectStreamEnd) {
if(round(beatTime + snapSelect, 5) !== round(game.timelineTickFor(successor[1]), 5)) {
if(round(beatTime + snapSelect, 6) !== round(game.timelineTickFor(successor[1]), 6)) {
return false;
}
}

// Check if it is snapped
if(round(game.timelineTickFor(predescescor[1]) + snapSelect, 5) !== round(beatTime, 5)
&& round(game.timelineTickFor(successor[1]) - snapSelect, 5) !== round(beatTime, 5)) {
if(round(game.timelineTickFor(predescescor[1]) + snapSelect, 6) !== round(beatTime, 6)
&& round(game.timelineTickFor(successor[1]) - snapSelect, 6) !== round(beatTime, 6)) {
return false;
}
};
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "PulseHax",
"version": "0.11.1-2",
"version": "0.11.2",
"description": "Hacking pulsus has never been so easy",
"permissions": ["storage"],
"host_permissions": ["https://pulsus.cc/*","https://www.pulsus.cc/*"],
Expand All @@ -13,6 +13,7 @@
"resources": [
"/Init.js",
"/editorMenu.js",
"/colorBankMenu.js",
"/assets/game/icon.ico",
"/assets/audio/retry.wav",
"/assets/audio/scroll.wav",
Expand Down
Loading

0 comments on commit 56826b9

Please sign in to comment.