Skip to content

Instantly share code, notes, and snippets.

foo()
.then(function(res) {
console.log('inside then 1: ' + res);
bar();
})
.then(function(res) {
console.log('inside then 2: ' + res);
});
foo()
.then(bar())
.then(function(res) {
console.log('inside then 2: ' + res);
});
foo()
.then(function(res) {
console.log('inside then 1: ' + res);
return bar();
})
.then(function(res) {
console.log('inside then 2: ' + res);
});
function foo() {
console.log('foo');
return new Promise(resolve => {
console.log('foo timeout before');
setTimeout(() => {
console.log('foo timeout');
resolve('foo resolved');
// 1
foo()
.then(function(res) {
return bar();
});
// 2
foo()
.then(bar);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
document.querySelectorAll('.item-word-progress').forEach(item => {
// show "Reset" button
item.click();
// click "Reset button"
document.querySelector('[data-tooltip="Reset the word status. It will show up during all the training sessions."]').click();
});
@ivantsov
ivantsov / kp-filter.js
Last active April 2, 2022 17:40
Filter movies premier by rating and voices count on the kinopoisk.ru (https://www.kinopoisk.ru/comingsoon/digital/?year=2021&month=12)
let MIN_RATING = 6;
let MIN_VOICES = 7000;
let movies = document.querySelectorAll('.premier_item');
[...movies].forEach((movie, index) => {
const ratingBlock = movie.querySelector('.ajax_rating');
const ratingElem = ratingBlock.querySelector('u');
const voicesElem = ratingBlock.querySelector('b');