From 19ef79dd58a0fedde61fdba9f2cd45beda10ac6b Mon Sep 17 00:00:00 2001 From: szialajoscosplay <70654182+k3rielit@users.noreply.github.com> Date: Sat, 6 Aug 2022 03:06:18 +0200 Subject: [PATCH] added commands, updated readme --- github/README.md | 12 ++++++++++-- github/lists.js | 24 ++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/github/README.md b/github/README.md index 128d58a..a580d14 100644 --- a/github/README.md +++ b/github/README.md @@ -5,11 +5,19 @@ - Paste it into the console - Change the `uid` (first line) to a GitHub account name - Press `Enter` +### Console commands (params are case sensitive): +- `starred`: displays the starred, but not listed items +- `lists`: displays the account's lists with their items +- `isItemOnList(item,list)`: returns `true` if the repo is on the list, otherwise `false` +- `IsItemUnlisted(item)`: returns `true` if the repo isn't on any lists, otherwise `false` +- `IsItemListed(item)`: returns `true` if the repo is on any lists, otherwise `false` +- `ItemsOnList(list)`: returns all the items on the list +- `ItemsNotOnList(list)`: returns all of the items that aren't on the list + - The `item` param can be the full repo URL, or the name only ### How to search if a list includes an item ([idea](https://github.com/orgs/community/discussions/28515)) - Run the script as written above -- Run the `isItemOnList(item, list)` command in the console +- Run the `isItemOnList(item,list)` command in the console - Case sensitive, expects the list's id (for ex. `asd-asd`, not `asD/* ASD`) - - `item` works with the URL and the title too - If it's on the list, it returns `true`, otherwise `false` ### How to disable the output - Delete the contents of the `finalize()` function. diff --git a/github/lists.js b/github/lists.js index 31760d3..c9fdb59 100644 --- a/github/lists.js +++ b/github/lists.js @@ -55,6 +55,26 @@ function finalize() { container.innerHTML = content+''; } +// Commands function isItemOnList(item, list) { - return lists[list].filter(f => f==item || f==item.split('/').last()).length>0; -} \ No newline at end of file + return lists[list].filter(f => f==item || f==item.split('/').last() || f.split('/').last()==item || f.split('/').last()==item.split('/').last()).length>0; +} +function IsItemUnlisted(item) { + return starred.filter(f => f==item || f==item.split('/').last() || f.split('/').last()==item || f.split('/').last()==item.split('/').last()).length>0; +} +function IsItemListed(item) { + for (const key in lists) { + if(lists[key].filter(f => f==item || f==item.split('/').last() || f.split('/').last()==item || f.split('/').last()==item.split('/').last()).length>0) return true; + } + return false; +} +function ItemsOnList(list) { + return lists[list]; +} +function ItemsNotOnList(list) { + let result = [...starred]; + for (const key in lists) { + result = result.concat(lists[key].filter(f => !lists[list].includes(f))); + } + return result; +}