Skip to content

Instantly share code, notes, and snippets.

View artzub's full-sized avatar
😊

Artem Zubkov artzub

😊
View GitHub Profile
import { parseResponse } from "core/request/RequestService";
import { getService } from "core/servicesProvider";
import { RequestMiddleware } from "core/request/RequestMiddleware";
export default abstract class BaseResource extends Resource {
static async useFetchInit(init: RequestInit): Promise<RequestInit> {
let preparedOptions: RequestInit = init;
const middlewares =
getService<RequestMiddleware[]>("DefaultRequestMiddlewares") ?? [];
@artzub
artzub / app-script.js
Last active March 17, 2024 16:28
YT Subs to WL
function findPlaylist(compare) {
let pageToken;
while(true) {
const list = YouTube.Playlists.list(['snippet'], {
"maxResults": 50,
"mine": true,
...(pageToken && { pageToken })
});
const item = list.items.find((row) => compare && compare(row));
const translate = (x, y) => `transform: translate(${x}px, ${y}px)`;
const show = (element) => {
const rect = element?.getBoundingClientRect();
let opacity = 0;
if (rect) {
opacity = 1;
leftTop.setAttribute('style', translate(rect.left, rect.top));
leftBottom.setAttribute('style', translate(rect.left, rect.bottom));
@artzub
artzub / part.js
Last active January 10, 2021 06:12
const checkHref = (element) => {
const tag = element.tagName;
return !(tag === 'A' || tag === 'AREA') || element.href;
};
const onFocus = (event) => {
if (
event?.target?.tabIndex > -1
&& current !== event.target
) {
// skip anchors and areas without href and disabled items
document.addEventListener('focus', onFocus, true);
document.addEventListener('blur', onBlur, true);
document.addEventListener('pointerenter', onFocus, true);
document.addEventListener('pointerleave', onBlur, true);
@artzub
artzub / part.scss
Last active January 10, 2021 06:00
.border {
position: absolute;
top: -4px;
left: -4px;
transform: translate(-20px, -20px);
transition: transform;
transition-duration: 0.1s;
border-style: solid;
border-width: 1px;
border-color: red;
<div class="overlay" id="overlay">
<div class="border border--leftTop" id="leftTop"></div>
<div class="border border--leftBottom" id="leftBottom"></div>
<div class="border border--rightTop" id="rightTop"></div>
<div class="border border--rightBottom" id="rightBottom"></div>
</div>
.overlay {
pointer-events: none;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1000;
transition: opacity 0.1s;
}
(function() {
const calc = (src, dest, graph) => {
const length = graph.length;
const distance = new Array(length).fill(Infinity);
const parents = [];
const visited = [];
let l = length;
let node;
distance[src] = 0;
@artzub
artzub / subscriptionToWL.js
Last active February 21, 2021 05:56
Add all subscription from the last watched to Watch Later Playlist
(function addAll() {
let neededVideoId = localStorage.getItem('_lastVideoId');
neededVideoId = neededVideoId || prompt('Enter id of the last video, or keep empty', '');
const delay = (ms = 100) => new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, ms)
});
const eventMouseEnter = new Event('mouseenter', {