Skip to content

Instantly share code, notes, and snippets.

View lukaszmn's full-sized avatar

Łukasz Nojek lukaszmn

View GitHub Profile
/**
* Enhances headers with names of parent headers
* If you have h2: 'abc' and h3: 'def', then h3 will be displayed as 'abc > def'
*
* @param {string} sectionSelector - id or class of the section that contains the headings, e.g. '#main'
* @param {number[]} headings - array of heading numbers that should be changed, in the order of processing, e.g.:
* [4, 3] -> for h4 show h3, for h3 show h2
* [3, 4] -> for h3 show h2, for h4 show h3 with h2
* @param {string} separator - the text between parent and child commit, by default it's '>'
* @param jQuery - reference to the jQuery
/**
* Enhances headers (or any elements) with link icons on hover
*
* sectionSelector: id or class of the section that contains the headings, e.g. '#main'
* elements: array of tags that should be changed, e.g.: ['h2', 'h3', 'h4']
* jQuery: reference to the jQuery
*
* Style the result in .header-link
*/
function addLinkIconsToHeadings(sectionSelector, elements, jQuery = $) {
/**
* Enhances headers (or any elements) with link icons on hover
*
* sectionSelector: id or class of the section that contains the headings, e.g. '#main'
* elements: array of tags that should be changed, e.g.: ['h2', 'h3', 'h4']
* jQuery: reference to the jQuery
*
* Style the result in .header-link
*/
function addLinkIconsToHeadings(sectionSelector, elements, jQuery = $) {
/**
* Enhances headers (or any elements) with link icons on hover
*
* @param {string} sectionSelector - id or class of the section that contains the headings, e.g. '#main'
* @param {string[]} elements - array of tags that should be changed, e.g.: ['h2', 'h3', 'h4']
* @param jQuery - reference to the jQuery
*
* Style the result in .header-link
*/
function addLinkIconsToHeadings(sectionSelector, elements, jQuery = $) {
@lukaszmn
lukaszmn / smoothScrolling.js
Last active August 24, 2019 09:16
Adds smooth scrolling to internal links with optional offset for top header - https://lukasznojek.com/blog/2019/08/automatically-enhance-headers-with-hierarchy-and-links/
/**
* Adds smooth scrolling to internal links with optional offset for top header
*
* @param {number} offset - optional offset to add when scrolling
* @param {number} duration - the duration of the animation, by default 800
* @param jQuery - reference to the jQuery
*/
function smoothScrolling(offset = 0, duration = 800, jQuery = $) {
jQuery('a').click(function() {
jQuery('html, body').animate({
// ==UserScript==
// @name Highbrow Labeler
// @namespace Violentmonkey Scripts
// @match https://gohighbrow.com/courses/
// @grant none
// @version 1.0
// @author Łukasz Nojek
// @description https://lukasznojek.com/blog/2020/01/course-movie-labeling-solution-using-firebase-and-violentmonkey/
// @require https://www.gstatic.com/firebasejs/7.6.1/firebase-app.js
// @require https://www.gstatic.com/firebasejs/7.6.1/firebase-auth.js
<html><body>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script>
<div x-data="{ items: [], adding: false }" x-init="$refs.ok.disabled = true">
<template x-for="item in items" :key="item">
<div>
<span x-text="item"></span>
<button @click="items = items.filter(i => i !== item)">DEL</button>
</div>
@lukaszmn
lukaszmn / netflix-list-exporter.js
Last active February 10, 2022 15:08 — forked from gonza7aav/netflix-list-exporter.js
Netflix | This will download your list as a JSON file
/*
Netflix - List Exporter
This will download your list as a JSON file
*/
/*
🚀 Usage
1. Go to Netflix
2. Go to your List
3. Open the browser console