Блог пользователя sigma_g

Автор sigma_g, история, 7 лет назад, По-английски

Hi all, I have made a dark theme for Codeforces. Solving problems on Codeforces at night becomes very tough due to the completely white theme. Even in the morning, staring at the white screen for long does not help people who develop eye strain quickly, like I do. Hence, I made this dark theme.

Quick access installation link

I was not content with simply using a color inverter for the website, as there are many subtle elements, especially the rating colors, which would lose their essence when inverted.

It will surely take your eyes some time to adapt to this new format of colors. However, I would really suggest you to use it for at least a day or two.

I have been using this daily for over two months now, so it's safe to assume it's very well battle-tested :) (except the problem setters page though, I am not really sure how that looks) I have added dark theme formatting for the source code viewer and submission editor as well!

Currently it's a userscript. Please find installation instructions on the GitHub repo. If enough people start using this, I might package this into a Chrome extension.

I would really welcome any constructive feedback that you have regarding it :)

Thank you!


Screenshot

  • Проголосовать: нравится
  • +108
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Its quite good and impressive. Do you have any suggestion for vscode theme that has similar color theme.

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Hi, thanks for your feedback! You might want to look into Monokai, that's the code styling sheet I used for this userscript. (Press Ctrl-K Ctrl-T to open theme menu, and select the Monokai theme in VS Code.)

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +58 Проголосовать: не нравится

If enough people start using this, I might package this into a Chrome extension.

Firefox users left the chat

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

great work...

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

This is lit. Great Work. Thank You

Now I'm writing the comments on a white background ( comment box's background is white ) and please make Codeforces logo dark too :)

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

For me the script doesn't work. I use Windows 10, test with the latest version of browsers Chrome, Firefox, Opera, Edge & with 4.8 version of Tampermonkey (latest too). Only facebook "likes" area in upper right corner became black, all other remained white. Could you help to fix it?

»
7 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится -37 Проголосовать: не нравится

Sale bherwe Teri maa chod dunga, Abe namard agar gaand me dem h to reply kar . Bhosdi wale Tere pichwade me goli Mar dunga.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I mean Dark Reader basically does the same thing.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

good work . Thanks.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Codeforces should have a default dark theme.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

if you want to change the logo to dark mode:

Install style as userscript

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

This is really amazing dude!! Thanks,i needed this :) Perfect Job!

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I need to change the font color and size(problem page),could you please point me which line to edit

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I'm not sure if I understood correctly, but mostly you can get the desired result by (1) inspecting the actual webpage to see which element selector (id, class) corresponds to the element you want to change (2) going to the userscript and finding that corresponding selector being used (3) adjusting the property values accordingly. If you cannot find these values then let me know via direct message.

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +5 Проголосовать: не нравится

sigma_g Kudos to your efforts. It's a great tool and enriches the experience of using codeforces.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In "status" page my submissions are not highlighted which used to be without the dark theme. If you could fix this it would be nicer. PS — Great job

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Thanks for this! Appreciate all the work you've put into it.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

Okay one question. I tried to install tapermonkey in the process and I shows me that it can read and "change" all the data on websites I visit. Does not it compromises my security just for a black theme ?

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +8 Проголосовать: не нравится

    TamperMonkey just basically acts as you to run scripts: but it's a lot more powerful than chrome's built in console.

    Because it needs to edit the webpage, it needs your permission. Of course, if you somehow download a virusy userscript, then of course, tampermonkey then becomes a much larger liability.

    • »
      »
      »
      6 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Pasting some suspicious script to TamperMonkey and telling it to run it (which I believe you will never do) is one issue, but the other is: what if TamperMonkey itself gets compromised to run some script you didn't tell it to do. You can (at least in Chrome) limit permission of any extension to particular domains. Just click in top right corner: extensions and when list of all extensions you have pops up click "more actions", go to "This can read and change site data" and limit its permission e.g. only to codeforces.

      • »
        »
        »
        »
        6 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +18 Проголосовать: не нравится

        And speaking of security of this script. sigma_g why does the script has following two lines:

        // @match https://calendar.google.com/calendar/embed* // @match https://www.facebook.com/v2.8/plugins/like.php*

        which, unless anyone installing it spots it and removes them, mean: TamperMonkey will run the script on on those domains as well. Moreover after I removed them, the dark theme on codeforces.com still works fine.

        • »
          »
          »
          »
          »
          6 лет назад, скрыть # ^ |
          Rev. 2  
          Проголосовать: нравится 0 Проголосовать: не нравится

          Hi, the first match URL is for the embedded Google calendar on the Codeforces Calendar page (hence the /embed) and the second is for the Facebook Like plugin that is present on the home page of Codeforces (for logged in users) (hence the /plugins/like.php).

          I'd like to clarify that these match directives won't let the userscript run on the entire domain, but only on the very specific path that has been mentioned. You can of course remove those two match directives and the extension will still work fine for the remaining pages. I wanted to support all the different components on Codeforces, hence I had added them in.

          If you're still unsure, you can check out the entire code on GitHub, in particular, the small JavaScript file with its very clear and descriptive code, to ensure it does nothing suspicious. If you're worried that my account may start pushing evil scripts in the future, you can also disable automatic updates for the userscript (enabled by default) from inside Tampermonkey.

          I completely agree with your concern for security, and I hope the above has helped clear any confusion there might have been. I try to be as transparent as possible in these regards, and would welcome additional comments/questions. Thanks!

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

There is one feature, that doesn't work at all with your plugin. It is highlighting last submission you've viewed in hacking mode red and all other you've viewed green. I added following code at the end of your script and it fixed it.

Sadly it's quite an ugly solution given it fetches all submission elements every second, but I couldn't come up with anything better, especially as it can be tested only during div1/div2 round.

function fix_colors() {
    var acceptedsubmissions = document.querySelectorAll('[acceptedsubmissionid]')
    var len = acceptedsubmissions.length
    for (var i = 0; i < len; ++i) {
        var elem = acceptedsubmissions[i];
        if (elem.style.backgroundColor == 'rgb(212, 237, 201)') {
            elem.style.setProperty('background-color', 'rgb(53, 92, 36)', 'important')
        }
        else if (elem.style.backgroundColor == 'rgb(255, 227, 227)') {
            elem.style.setProperty('background-color', 'rgb(89, 43, 43)', 'important')
        }
    }
}
window.setInterval(fix_colors, 1000)

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +10 Проголосовать: не нравится

    You can probably make it a lot less expensive by replacing document with the lowest common DOM container of all the [acceptedsubmissionid] nodes (so lcdc.querySelectorAll instead of document.querySelectorAll).

    I'll not merge this into the main repo since, as you said, it's a per second computation, and it doesn't seem to be super relevant to most people. And anyone who wants to add it can add from your comment.

    In any case, thanks again!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Its awesome thanks a lot

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Just to prevent another monkey from making the same mistake as myself, the steps in which you download everything matters. I originally downloaded the code, then the script, and then pasted the code into Tampermonkey. Took me half an hour to realize I should have let Tampermonkey do its thing ):

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This is not working, is it changed ? I installed tapermonkey, added script to it. But not changing the color to black, something else i am forgetting here ?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why do people like dark theme rather than light theme ?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

wow thanks that helped so much

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Great work! I really like the theme. However the little icons for things like country flags, the paper-airplane and "favourite problem" buttons in problemset, etc. have a square white background which I find eerie. Is it just for me? If not, it would be great if you could fix it!

  • »
    »
    5 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +4 Проголосовать: не нравится

    This is a recent issue (<1 month). Actually, earlier I thought the issue is because of some change from Codeforces server side, because this issue had started occurring without me pushing updates to the userscript.

    But, now, I noticed there was some minor CSS issue in my userscript. I don't know how it was working earlier.

    I have fixed it and pushed the update. You should get the auto-update within 2 days, or you can manually reinstall the userscript from the same GitHub page. Cheers!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Hey ,it is not working on brave browser . Any one any idea about it .Also did u made an extention of this theme ?? Please help this white thing is having too much stress .

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Please make this into a chrome extension

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

why don't you just create an extension it will be easy to install....

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

CodeForces multiple test cases color is updated, please update input test cases color

»
2 года назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

wow the script still works!

»
18 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is it just me or the script has suddenly stopped working on Chrome

It was running fine till yesterday and other scripts through tampermonkey seem to work fine but this one stopped suddenly?

  • »
    »
    18 месяцев назад, скрыть # ^ |
    Rev. 4  
    Проголосовать: нравится +3 Проголосовать: не нравится

    I think it has stopped after the auto-update of tampermonkey.. maybe the author would do smth about it.. hopfully

    UPDATE 1: it worked just fine after rollingback from tampermonkey 5.3.1 to 5.3.0, I don't exactly know why but I will come back after reading the change log of the new versoin (5.3.1) of tampermonkey

    UPDATE 2: I think that it is either a problem with the importation process of the 3 resources cited at the beginning of the userscript code, or the current implementation of those resources on the new environment of Tampermonkey. Either way, I replaced them with the following resources from the "Codeforces Dark Mode" user script -different than the dark THEME's- and it worked just fine! the new resources: // @resource desertCSS https://github.com/LordLava/codeforces-darktheme/raw/master/desert.css // @resource monokaiEditorTheme https://raw.githubusercontent.com/ajaxorg/ace/master/lib/ace/theme/monokai.css // @resource darkthemecss https://github.com/LordLava/codeforces-darktheme/raw/master/darktheme.css

    NOTE: each "//" represents the beginning of a new line, nd for clarity: the above three lines were replaced with the lines 10, 11, and 12.

    UPDATE 3: Another workaround that worked for me is to just switch to the beta version of tamper monkey without doing anything else. In other words, just remove the tampermonkey extension, install the beta version of it, then install the codeforces dark theme userscript and it should work just fine! Apologies for taking much of your time.

»
16 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +1 Проголосовать: не нравится

This feature is currently disabled, Is there an alternative?

»
9 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Not Working

»
7 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

this helps my eyes A LOT bro thx

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Bro ure a lifesaver thanks <3