I need help with edit addon (chrome)

So, i have ONE addon, but TWO version of it. 1. old version, with few different functions, which the NEW version doesnt have.
Because i dont understand javascript, i did only one change successfully, so one feature from old version is now in new version.
But after a month of trying, i just cant make other features working.

Can someone help me with it? For someone who know what he do, it will be just about few looks on code. For me it is like chinese font :confused:

That addon is simple, nothing hard i bet, nothing illegal.

2 Likes

if you show us the code we might be able to help you :>

Well, yeh, my bad, but i dont know how to upload whole addon, or what exactly you need from both of them

Bruh, just get your mouse and select the whole-code section/block you want to share to be inspected/checked here and copy it here with a code goes here <-in this format which is select the code/text and click the </> button here on (is number 6) top of the text-box to reply/post.

1 Like

My first thought about ā€œhow to do itā€ was like "ok i dont need to see ā€œmedal rewardsā€ so i can use ā€œbodyā€ from it, to implement just the ā€œsnipeā€ code from older version. But my attemps wasnt successfully.

Also, in new version, there is switch in names, but code looks same, as in old version, but in new version is ā€œSaveRankCostā€ , in old version is name ā€œSnipeRankCostā€

let ForderStates = [],
			SaveStates = [],

vs

let ForderStates = [],
			SnipeStates = [],
1 Like

Bruh, do you have any sort of documentation we can look in regards to these add-ons for chrome, so we can look at ? I mean what is it that you trying to do, whatā€™s wrong with it?

I can upload both full version of addon, if it helps?
it is ā€œfoe helperā€ addon
In the folder are many files, like:
_locales
content
css
images
jss (inside is: web(inside is: _api, _helper, _i18n,_languages, _main, _menu, calculator) , background.js, inject.js, popup.js,text-pop.js)
vendor
manifes.json

calculator folder is the one, which should be modificate, but it must be connected with other folders i think, and that is another problem, because i dont have idea which

1 Like

okay but what does this addon does? Can I get it to test it out? You see Im trying to help here bruh. :L

here is link for oficial version (latest one).
Same addon was half year before with ā€œsnipeā€ function in calculator, but it was removed. I want it just back.
What does snipe function? In game there are building, you can put inside forgepoints to contribute reward. Snipe function calculate the minimum safety contribution of forge points.

there is link for code page for whole addon.

or simplier in this link are both version of addon.

What i need is, if someone can put ā€œcalculatorā€ from old version (2.4.) and put it in the new version (2.5.) and make it function in new version.
Just change calculator (js->web->calculator) in new version, to the calculator in old version. (copy paste folder calculator, and change code in other connected folders to accept old version in new version code)

also if you can do this, maybe you will know, how to add also ā€œread buildingsā€ feature (js->web->read buildings) (it is in old version, but missing in new version)

you can download it by click on ā€œturttle iconā€
2.4. is old version
2.5. is latest version

Edit: i cant post more than 7 posts a days, so i must edit.

Well on github is only the latest version(2.5) of addon, so also calculator. But i would like to have old calculator (2.4) in the latest version (2.5)

I saw in the github repo the calculator script, is that the v. 2.4?

1 Like

Well on github is only the latest version(2.5) of addon, so also calculator. But i would like to have old calculator (2.4) in the latest version (2.5)

I can write only 7 post a day, so i must use edit :slight_smile:

Well what about you substitute the calculator folders, from 2.4 to 2.5 ?

I already tried it, copy paste folders. But as i wrote, it doesnt work. I think, that there must be change also something in folders like ā€œapi, mainā€. But because i dont have idea , how this ā€œchinese fontā€ function, i cant see ā€œwell this part of code refer to folder ā€œ_mainā€ in 447 line, so i need to edit also hereā€.
That is why i asking on this forum, you guys didnt saw this kind of ā€œchinese fontā€ for first time like me :smiley: You can see all connection bettween lines, i simply cant.

When i wanted to change(copy paste) code for calculation ā€œmedals rewardā€ to ā€œsnipeā€ code. Because i wanted to use already set ā€œbodyā€ for ā€œmedal rewardā€ (because i dont have idea how to create own body for ā€œsnipeā€ or i even cant distinguish code from old version 2.4 ā€œsnipe bodyā€ , to just substitute code for it in new version.

What i find is, that in old version, it is called ā€œsnipeā€¦ SnipeRankCost etcā€¦ā€
in new vrsion it is in code called ā€œSaveā€¦SaveRankCost etc. ā€¦ā€
The think is, that in old version everything (medal, forge points, blueprints) are in code

So what exactly is different between ā€œMath.roundā€ vs ā€œMainParser.roundā€?
I can try substitute every ā€œMainParser.roundā€ in new code, to ā€œMath.roundā€ from old code. Does it help? Or i will mix two different things?

When u say chinese font u donā€™t literally mean that, right? Because I know not Chineseā€¦

Ofc, as i wrote in first post, for me is this code like ā€œchinese fontā€ :smiley:

Hi, i have a little bit problem with editting existing extension for google chrome. It is extension for web browser game, nothing illegal. Just there exist two version of extension. 1. old ver. 2.4 and second the latest.
My problem is, that in latest, author of extension changed style of ā€œcalculatorā€, so i want to change it to the old one, from version 2.4.
I have both version dowloaded (NovĆ” složka.rar | Ulož.to (for download click on the turtlle icon))
So, i had an idea, that i will just copy and paste code from old calculator to the new calculator. jss. But it doesnt work ofc, because i dont have idea what to change in code, what is reffering to new code to accept old one calculator.

What i find is, that in old version, it is called ā€œsnipeā€¦ SnipeRankCost etcā€¦ā€
in new vrsion it is in code called ā€œSaveā€¦SaveRankCost etc. ā€¦ā€
The think is, that in old version everything (medal, forge points, blueprints) are in code

SnipeRankCosts[Rank] = Math.round((Calculator.Rankings[j]['forge_points'] + RestFP) / 2);
						break;

and in new version everything (medal, forge points, blueprints) are in code

SaveRankCosts[Rank] = MainParser.round((Calculator.Rankings[j]['forge_points'] + RestFP) / 2);
						break;

So what exactly is different between ā€œMath.roundā€ vs ā€œMainParser.roundā€?
I can try substitute every ā€œMainParser.roundā€ in new code, to ā€œMath.roundā€ from old code. Does it help? Or i will mix two different things?

Because for me is all this coding like trying to read chinese font, so that is why i asking help here. You already see this type of problems and you know what to do with it, also when i will take a look on code, i simply cant see that ā€œthis link is connected to another one in different folderā€ :confused:

I donā€™t know what ā€œMainParserā€ is, I assume it is a specific module to this project. Without seeing its code, we canā€™t tell what ll it does. Presumably it ā€œroundsā€, but there may be something else going on. The other problem is that the results here are being assigned to different variables, the first one to SnipeRankCosts[Rank] and the second to SaveRankCosts[Rank] - are you sure these are the same sections of code?

Yeah, you have to be careful about swapping things out like this. It would a lot depend on how close the code is. Swapping parts in a 2006 Prius and a 2007 Prius might work, but if itā€™s a 2007 Prius and a 1967 Mustang, it gets a lot more difficult.

Well, in another thread (i tought that extension is javascript) i copy and paste whole code for ā€œcalculatorā€ in both version, you can take a look(I need help with edit addon (chrome) - #3 by abcklm), or just download both version which i included in first post.
So yeh, for me, code looks same, but with different names and this "math. round and mainparser

So, to answer your question

So what exactly is different between ā€œMath.roundā€ vs ā€œMainParser.roundā€?

Looking in _main.js, that is where MainParser is defined. That specific method is defined as:

	/**
	 * Performs rounding taking into account floating point inaccuracy
	 *
	 * @param {number} value
	 * @returns {number}
	 */
	round: (value) => {
		let Epsilon = 0.000001;

		if (value >= 0) {
			return Math.round(value + Epsilon);
		}
		else {
			return Math.round(value - Epsilon);
		}
	},

So heā€™s building in some fudge factoring into his round functions. Heā€™s defined a custom epsilon - Iā€™m not sure why he didnā€™t use the system epsilon. If you donā€™t understand what I am talking about, google ā€œ0.1 + 0.2 javascriptā€.

So, itā€™s just an ever so slightly adjusted rounding method. My guess is that 99% of the time it will have no effect and when it does, only slightly. I would not expect it to have catastrophic results, but maybe there are other parts of the code that are dependent on that.

It looks to me like there are some non-trivial changes between these two versions. Without knowing a lot more about the code, I would not want to go swapping out things.

One thing to try, if you want to see if the new rounding is affecting things, would be to just go into _main.js and change that method to:

	round: (value) => Math.round(value),

Itā€™s also possible that:

	round: Math.round,

would work.

These would revert to the ā€œoldā€ rounding anywhere this method is used.