Skip to content

Instantly share code, notes, and snippets.

const SEARCH_INPUT_SELECTOR = 'div[role="search"] input[role="searchbox"]';
const ADD_BUTTON_SELECTOR = 'div[role="presentation"] > div[role="row"] button[aria-label="Add to Playlist"]';
const input = document.querySelector(SEARCH_INPUT_SELECTOR);
const tracks = ['test'];
const wait = async (timeout) => new Promise((resolve) => setTimeout(resolve, timeout));
const findTracks = async (track) => {
const TRACKS_SELECTOR = 'div.d-track__overflowable-column > div.d-track__overflowable-wrapper.deco-typo-secondary.block-layout';
const TRACK_NAME_SELECTOR = '.d-track__title';
const TRACK_VERSION_SELECTOR = '.d-track__version';
const TRACK_ARTISTS_SELECTOR = '.d-track__artists > a';
const trackElements = document.querySelectorAll(TRACKS_SELECTOR);
const tracks = [];
trackElements.forEach((trackElement) => {
const name = trackElement.querySelector(TRACK_NAME_SELECTOR).innerHTML.trim();
const version = trackElement.querySelector(TRACK_VERSION_SELECTOR)?.innerHTML.trim();
@aescarcha
aescarcha / nodeAsyncTest.js
Created September 25, 2018 07:03
Javascript async / await resolving promises at the same time test
// Simple gist to test parallel promise resolution when using async / await
function promiseWait(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, time);
});
}
@primaryobjects
primaryobjects / m3u8.md
Last active May 8, 2024 09:27
How to download m3u8 and ts video movie streams.

m3u8 Downloading

  1. Open Chrome Developer tools and click the Network tab.
  2. Navigate to the page with the video and get it to start playing.
  3. Filter the list of files to "m3u8".
  4. Find master.m3u8 or index.m3u8 and click on it.
  5. Save the file to disk and look inside it.
  6. If the file contains a single m3u8 master url, copy that one instead.
  7. Run the program m3u8x.
  8. Paste the same m3u8 url in both textboxes (URL and Quality URL) and click "Headers" and set the referral url and user-agent from the request as found in Chrome.
@monicao
monicao / react.md
Last active February 23, 2021 19:07
React Lifecycle Cheatsheet

React Component Lifecycle

  • getInitialState
  • getDefaultProps
  • componentWillMount
  • componentDidMount
  • shouldComponentUpdate (Update only)
  • componentWillUpdate (Update only)
  • componentWillReceiveProps (Update only)
  • render
@mogelbrod
mogelbrod / index.js
Last active March 17, 2019 17:16
Simple apply-loader module for webpack, published @ https://www.npmjs.com/package/apply-loader
var loaderUtils = require('loader-utils');
module.exports = function(source) {
this.cacheable && this.cacheable();
var query = loaderUtils.parseQuery(this.query);
var args = [];
// apply?config=key => sourceFn(require('webpack.config').key)
if (typeof query.config === 'string') {
if (!query.config in this.options)
@magicznyleszek
magicznyleszek / css-selectors.md
Last active March 29, 2024 01:12
CSS Selectors Cheatsheet

CSS Selectors Cheatsheet

Hi! If you see an error or something is missing (like :focus-within for few years :P) please let me know ❤️

Element selectors

Element -- selects all h2 elements on the page

h2 {
@hsablonniere
hsablonniere / README.md
Created May 2, 2012 22:42
scrollIntoViewIfNeeded 4 everyone!!!

scrollIntoViewIfNeeded 4 everyone!!!

This gist provides a simple JavaScript implementation of the non-standard WebKit method scrollIntoViewIfNeeded that can be called on DOM elements.

Usage

Just use the code in index.js in your app or website. You can see usage in the test page test.html.

The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.

@realmyst
realmyst / gist:1262561
Created October 4, 2011 19:34
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);