Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Want to help #174

Closed
jansedlon opened this issue May 12, 2020 · 3 comments
Closed

Want to help #174

jansedlon opened this issue May 12, 2020 · 3 comments

Comments

@jansedlon
Copy link

Hi! I've just found this repo and it looks amazing! I would like to help you somehow. I'm a frontend developer (mostly React) as well as backend developer + some devops things. I've looked at the code and it's quite complex and your developer docs are in progress. Is there any way that you could introduce me how this works? Thanks!

@GramThanos
Copy link
Member

GramThanos commented May 13, 2020

The main idea is that each page has 1 script that contains the features targeting that page. Additionally, there is one script that runs on every page (name "global").
All these script are located at "/source/core/source/". For example, the script named "overview.js" runs at payer's overview web-page.

These scripts are loaded by the "manager.js" located at "/source/core/". The manager script runs with "extensions rights", while the scripts it imports run with "web-page rights" (injected inside the page).

At the bottom of each page script you will find a loader snippet that waits for the page to load. At the top of the code you will find the script's object. For example the overview script, defines the gca_overview object.

As soon as the DOM is ready, the inject function of the script's object is fired (e.g. gca_overview.inject() ). Some scripts also feature a preinject function that runs as soon as possible, usually to apply CSS on the HTML tag, in order to avoid bad visual experience.

Some scripts are special and are injected on the page before any other script. For example the gca_tools script, that holds functions need by many pages. Also, gca_data that is the local storage manager and of course the gca_info script that does the page url analysis, like gca_section.mod and gca_section.submod and also gca_getPage.link(parameters).

Adding a feature:
Lets say we want to make the player's title red (with javascript).
First we define the code under gca_overview. If our code is more than one function, we add it under an object. In this example we just have 1 function so we can define it at

gca_overview.makeTitleRed = function () {
... // RED!
}

This function should then be called from gca_overview.inject. After debugging we enable an option to turn it on and off. We define the default value inside the gca_data.js script, at the gca_options.data.overview.red_title = false (default turned off)

Now we can add it to the call code we added on inject with a (gca_options.bool('overview', 'red_tile' && this.makeTitleRed());

Then we will have to place the options at the settings page, inside the settings.js (search for overview), the format there is like the gca_data.js but supports functions as values. It is automatic for known types like booleans.

Lastly, you need to add at least the English translation of the item you just added on the settings page. To do so, you can go to the settings page (on browser) at the overview category, there will be an "undefined translation" id instead of a text, copy it and add it at the /source/core/locale/en.js (you will understand where it goes... all the settings related translations are together).

@FrutyX
Copy link
Collaborator

FrutyX commented Dec 16, 2021

@Zitronenen you think you can extract this useful info that Gram wrote and add it to the docs (developers)? You created most them, so it is better you do it, so we don't break your format.

You can request an pull request, I'll have a look at it.

Also there is this #175, talk about open sourcing, you can read I know, but to sum it up, they are willing to share the code only if someone will actually contribute to it.

The goal here is to create a little FAQ for developers, and you don't have to look for it everywhere in different Issues.

But only if you want, I am not forcing you into it :-).

@FrutyX
Copy link
Collaborator

FrutyX commented Dec 22, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants