Skip to content

Commit

Permalink
added commands, updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
k3rielit committed Aug 6, 2022
1 parent 3cbaf00 commit 19ef79d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
12 changes: 10 additions & 2 deletions github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
24 changes: 22 additions & 2 deletions github/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ function finalize() {
container.innerHTML = content+'</table>';
}

// Commands
function isItemOnList(item, list) {
return lists[list].filter(f => f==item || f==item.split('/').last()).length>0;
}
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;
}

0 comments on commit 19ef79d

Please sign in to comment.