Giter VIP home page Giter VIP logo

polyglot's Introduction

polyglot

TamperMonkey user script which improves user experience with Codewars (or at least tries to).

WHAT IS IT?

This piece of code is a Tampermonkey user script which provides some additional per-language filtering and display capabilities, effectively making it easier for you to obtain POLYGLOT badge.

WHERE CAN I DOWNLOAD IT FROM?

You can get the script here.

HOW TO INSTALL IT?

  • Install Tampermonkey extension for your browser,
  • Copy&paste the script to your scripts library.

WHAT FEATURES DOES IT PROVIDE?

  • You can copy content of code boxes into clipboard.
  • "Spoiler" flags are visible all the time and do not dis/re-appear in a very annoying manner.
  • Contents of "Solutions" and "Past solutions" views are displayed in tabs by language.
  • Leaderboards: "Solved kata is default leaderboard (since "Overall" ranking does not measure anything useful). Also, leaderboards are automatically scrolled to show your score.
  • Beta kata: uses Codwewars API to fetch and present breakdown of rank votes.
  • Presents languages a user attempted the kata with (see below).

HOW TO UNINSTALL IT?

I haven't checked.

KNOWN ISSUES

  • Yes.
  • A race condition here or there.
  • Selectors, hooks and listeners used are so inefficient that your local power plant probably doubles its coal consumption.

WHAT CAN I DO WITH THE SCRIPT?

  • You are allowed to use it, unless someone authoritative (CW staff?) says you can't.
  • You can modify it ONLY IF your modifications are going to bring any improvement into the way it works, AND you are going to share improved version with CW community.
  • You can send all your critical remarks to /dev/null, unless it's something I could learn or otherwise benefit from - in such case, you can contact me on Codewars Discord server.

THIS CODE IS CRAP, LOOKS LIKE CRAP, AND WORKS LIKE CRAP! WHY?

I am really sorry if this code hurts your eyes, brain, or feelings in any way, but I am not a professional HTML developer and each and every technique present here (JavaScript, jQuery, TamperMonkey, CW API) I've used for the first time.

CREDITS

  • Codewars
  • TamperMonkey
  • StackOverflow
  • jQuery
  • notify.js
  • Chart.js

How to use "Show attempted languages" feature?

For technical reasons, a user script is not able to get data necessary for this feature without some additional setup. You need to provide a session ID which is used to identify a logged in user. The value can be read with developer tools from the _session_id cookie, and needs to be entered into the "Codewars session ID" input in Polyglot settings dialog.

When the feature is enabled and properly set up, it's possible to view languages a user attempted the kata with, by clicking on "Attempted languages" link under discourse posts. If a language appears as stroke through, it means that a viewing user cannot see the solution becaue they didnt complete the kata in this language. If a language name is clickable, it means that a viewing user is eligible for viewing the solution and can use the link to change the current language to the clicked one, and use the "View solution" expandable panel to see the code of the most recent attempt.

polyglot's People

Contributors

blind4basics avatar haksell avatar hobovsky avatar kacarott avatar madjosz avatar wtlgo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

polyglot's Issues

Filter discourse threads by resolution status

Currently CW provides no way to view only resolved/unresolved issues, questions or suggestions, and such possibility could be useful. For example it would help to see what are the pending issues which prevent approval of a beta kata.

Suggestion - solutions autoupdate

current behavior

The user needs to go to his "Solutions" page so that the script updates its "database".

"would like" behavior

a way so that the script automatically do that.

suggestions:

  • frequency:
    • daily update?
    • update at first connection of the day to CW (local time)?
  • restrictions to use:
    • download only the first page of the solutions? (tho, that could miss some solutions, that way, for users who do looong streaks in one day)
    • better: to find a way to keep in memory the last solutions already archived? (tho, that will be tricky because the order of the solutions might change... :/ Might not be a very good idea/way)

cheers!

Reassign keyboard shortcuts for trainer buttons

Buttons "Run sample tests", "Attempt" and "Submit final" have keyboard shortcuts which use quite annoying key combinations (for example, Ctrl+S). It would be a nice feature to disable or reassign key bindings for these buttons.

Remove Polyglot search filters

Search filters of Codewars were modified to generally replicate functionality of Polyglot filters: now, when a language is selected, the "Progress" filter field considers selected language.

Filter dropdown added by Polyglot is not needed anymore and can be removed.

Issues after UI update

Class of items on "Completed solutions" t ab changed, causing two things to fail:

  • list of completed kata is not updated, causing language icons to not update
  • completed solutions are not tabbed

Settings panel only opens on freshly reloaded pages

To show the settings panel I have to refresh the page beforehand. When I navigate to other pages and then try to open the settings panel only the gray overlay appears covering the site elements but the settings dialog does not show up and I have to navigate to another page or refresh to get rid of the overlay (header and sidebar menu still clickable as they are above the gray layer).

Browser: Opera 86.0.4363.59
OS: Windows 10 64-bit

Request - control the leaderboard redirection target from config panel

It could be nice if the user could select to what leaderboard the related menu link would be reassigned. Especially now that the ranks one exist (note: language specific boards are also possible: ranks?language=python).

Possible simpler way: having the tail of the url defined in something like const LEADERBOARDS_TARGET = 'ranks' at "an easy place to find" in the script would be already good. Like at the very beginning or thee very end (currently, I have to search through the entire file each time I recieve an update, which is a bit annoying)

Limit bandwidth usage

Linked to the previous one (#1): currently, each update load the whole lot of solutions, while in most cases only a few bunch of those would need to be. That would be good (for cw's servers too) that a limitation can be put on this.

problem:

require to find how to be sure to identify what's needed to be downloaded or not.

  • archiving the last completed kata won't be enough. Leads to a wrong update in the following case:

    1. last update of solutions done, archiving the kata at the top of the list as "limiter"
    2. new katas done by the user (let's say 10 new ones)
    3. the user complete the "limiter" in a new language
    4. new update of the script => it will miss the 10 new ones
  • 'just thought that maybe you could just store the date of the last update and download the pages until you reach a date that is older than the last update? Surely better, yes x)

cheers!

Format dates as timestamps

Currently CodeWars renders most of the dates and timestamps as "time passed" string (Yesterday, 2 weeks ago, 3 years ago) what presents information in a fuzzy way. While it's not usually a problem, sometimes user would like to know an exact point in time: When was an issue raised? When was a translation published? Did X happen after, or before Y? Option to format timestamps as dates or datetimes could be useful in such cases.

In most cases, DOM provides enough information to render timestamps as exact dates and times.

Provide a way to collapse description and tests

When kata is solved, "Solution" and "Discourse" tabs contain expandable sections "Show Kata description" and "Show Kata test cases":

image

Once expanded, sections cannot be collapsed anymore what often makes page really long. Provide a way to collapse them back.

Solved katas show in results when "Show katas I haven't solved" is selected

I used this script today after some time:

  • I update the solutions tab
  • I select the filters on the left: language: Kotlin, status : both, progress: Kata I have completed
  • I select "Show Katas i haven't solved in Kotlin"

Screen Shot 2020-12-01 at 13 41 57

The results contain also kata which I have completed in Kotlin and sometimes even fails to "fade out" the language logo. For example, the Bouncing Balls kata in the screenshot, I have completed this in 4 languages.

Is there a step I'm missing? I must admit I haven't used this in some time now.

The script is updated to the latest version

Add possibility to filter kata search by author

Currently, kata search supports author parameter, but it's not exposed via UI.
Kata can be searched by author using q parameter: https://www.codewars.com/kata/search/my-languages?q=author%3Ag964&beta=false
The search can be exclusive with -author.

Provide link to kata page in translation views

Various pages related to translations: list in user profile, fork views, edit panels, do not provide easy access to the kata page itself - user has to navigate to translation first, and then to related kata.

Add a link which would lead directly to kata details instead of kumite/fork view.

Leaderboards: Scrolling

Currently there is no scrolling, when you load this page, it immediately "jumps" to the name without showing the upper ones.

But with this.scrollIntoView({ behavior: 'smooth', block: 'center' }) it would be really scrolled and the own name is then also in the middle.

Add info on voters in rank assessment breakdown

"Get Rank Assesments" endpoint returns IDs of voters when requested by moderators, but this information is not presented anywhere in the breakdown chart.

Add some functionality which presents voters on mod's request, even if just a link to raw JSON response.

Auto-refresh solutions

Here is a Tampermonkey script to refresh the completed_solutions tab automatically:

// ==UserScript==
// @name     AutoRefreshCodewars
// @include  /https:\/\/www\.codewars\.com\/users\/\w+\/completed_solutions\/
// ==/UserScript==

let seconds = 180;
setTimeout(function(){ location.reload(); }, seconds * 1000);

Needs the tab to be open but at least you don't need to visit it every time.
Maybe you could include it in polyglot.

Polyglot settings form is "leaking" in some pages

image

-> look in the blue area, there is text "hidden" behind the nav bar and the comment section.
I've spotted the corresponding html tree in the console, it's the polyglot settings.

I believe the problem occurs as well in the solution-stats pages: when I use page-down while being at azoom level of 30%, I constantly see something moving up from the lower left corner of the page, then it disappears again.

Might be related too: pick a solution-stats rank page where you don't have enough entries to fill the page and each time I click "that button", I have the slider appearing and disappearing. It's pretty annoying... And I think it's coming from your script pushing the form below the current visible part of the page (== slider appears), then hidding it (==slider disappear)

Provide means to de/activate individual features

There are situations when some users would like to use only a subset of functionalities, for example:

  • They do not like it,
  • It causes problems in their browser.

Currently it's 'use all features, or nothing', while it would be nice to give users some options.

Add rank assessment breakdown for beta kata

From kazk:

For this feature, I'll add /api/v1/code-challenges/:id/assessed-ranks that responds with JSON like

type Response = {
  data: Count[], // ordered decending by count
};
type Count = {
  rank: number,
  count: number,
  users?: string[], // user ids, only if requested by mods
};

{
  "data": [
    {"rank": -7, "count": 4},
    {"rank": -6, "count": 2},
    {"rank": -1, "count": 1}
  ]
}

Add language filters in UI to "Pending translations" view

Some users have access to "pending translations" view. By default, translations are filtered by "my languages", but URL accepts languages param with a comma-separated list of language tags. However, this functionality is not exposed via GUI.

Add rank assessment breakdown chart in kata editor

To approve a kata, user has to enter the kata editor and assign a rank to it, but breakdown chart is not displayed there and it's not easy for approvers to check for the most suitable rank.

Find a good place in kata editor to put the chart at, so approvers could use it to estimate the best suitable rank.

Add links between kata areas

Navigation could be improved by adding some links, for example:

  • From kata trainer to kata details/description page
  • ... other ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.