-
-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Welcome to the Codeforces++ wiki, the official documentation for this project. Here's some information to get you started:
We use rollup to bundle the javascript and yarn as the package manager. To build in watch mode just run yarn start
in your terminal, or yarn build
to build in production mode. The outputs will be in the dist/
directory. As of now, building will yield 2 outputs: one to use as an userscript and the other, a browser extension.
Entry-point files are located right at src/
. The .js that runs the Codeforces++ core functions is index.js
, it calls every module that's needed for the userscript to work. In this folder you can also see the contentScript.js
, background.js
, popup.html
and popup.js
, these are used exclusively in the browser extension.
There are 3 main folders in src/
: helpers/
, env/
and ext/
:
- helpers: The misc folder
- env: Environment modules. These provide a kind of API for the other modules to communicate with their environment e.g. stuff that's done differently in the extension/userscript and DOM-related utilities. Also the configuration module.
- ext: Extensions. Every module here provides some new functionality to Codeforces, and exports the
install()
anduninstall()
methods, soindex.js
can use them appropriately.show_tags.js
, for example, will add a "Show Tags" button instead of the actual tags in a problem page when installed, and remove it when uninstalled.
This project uses JSX to increase readability, but there's no React involved. helpers/dom.js
provides the element()
method to create DOM nodes, like React.createElement
would. For example, let a = <a href="javascript:alert(1);">Click Here</a>;
becomes, after transpiling, let a = dom.element("a", { href: "javascript:alert(1);" }, "Click Here");
.
- Why are you using
env.global
? What's this?- The "global" variable when building for a userscript is
unsafeWindow
(window
is not able to accesswindow.Codeforces
for... reasons), but the browser extension useswindow
.env.global
will be one of these, accordingly.
- The "global" variable when building for a userscript is
- What's a "Functional.js"?
- It's like Ramda, but only a fraction of it and has some other functions I thought would be useful. You can read
helpers/Functional.js
asmisc/misc.js
, it won't make too much of a difference.
- It's like Ramda, but only a fraction of it and has some other functions I thought would be useful. You can read