Skip to content

Instantly share code, notes, and snippets.

@moriglia
Last active July 14, 2020 13:42
Show Gist options
  • Save moriglia/bc05fd9b9e26412a902b1e786ed20e7d to your computer and use it in GitHub Desktop.
Save moriglia/bc05fd9b9e26412a902b1e786ed20e7d to your computer and use it in GitHub Desktop.
Microsoft Streams sorts videos by Trending, but lessons are easily found if sorted by Publish Date. This script authomatically selects this latter option.
// ==UserScript==
// @name MicrosoftStreamSortByDate
// @include /^https?://web\.microsoftstream\.com/group/.*\?view=videos$/
// ==/UserScript==
/* Use this script to sort videos
* by Publish Date automatically
* on Microsoft Stream.
* Inport this script in GreaseMonkey
*/
async function sortByPublishDate() {
// find the selector class element and expand
selectors = document.getElementsByClassName("selector");
while(!selectors.length) {
await new Promise(resolve => setTimeout(resolve, 500));
selectors = document.getElementsByClassName("selector");
}
// click to expand options (seems silly but it didn't work without expanding)
selectors[0].click();
// find sort by Publish Date option and trigger click
await new Promise(resolve => setTimeout(resolve, 500));
items = document.getElementsByClassName("option-item");
items[3].click();
console.log("Videos Sorted by publish date!");
}
sortByPublishDate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment