Skip to content

Instantly share code, notes, and snippets.

@vneri
vneri / deepQuerySelectorAll.js
Last active December 29, 2021 15:37
JavaScript querySelectorAll for all children and shadowRoot elements
function deepQuerySelectorAll(actual, selector){
var results = [];
// search for children
if (actual.shadowRoot != null){
deepQuerySelectorAll(actual.shadowRoot, selector).forEach( el => results.push(el));
}
if (actual.children !=null){
Array.from(actual.children).forEach(
@vneri
vneri / createRandomReadablePassword.js
Last active February 16, 2021 17:06
Create readable, pronounceable, memorable passwords in JavaScript with flexible, translatable dictionaries
if (! window.readablePasswordDictionary){
window.readablePasswordDictionary = [];
}
// you can also provide custom ones, by adding another language set
window.readablePasswordDictionary['de'] =
[
'Anfrage', 'Bestellung', 'Produkt', 'Adam', 'Entdeckung', 'gewisse', 'Gewissen',
'Zeit', 'Socken', 'super', 'Deutschland', 'Berlin', 'Hannover', 'Hamburg',
'zusammen', 'sicher', 'genauso', 'gegen', 'entgegen', 'exzellent', 'aktuell', 'Feier',
'Gestaltung', 'Event', 'eventuell', 'geradeaus', 'Inspektion', 'Sicherheit',
@vneri
vneri / index.html
Last active June 19, 2020 07:05 — forked from danielpradilla/index.html
HTML5 skeleton, without external libraries and css
<!DOCTYPE html>
<html>
<head>
<title>title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
</head>
<body>
<h1>Hello, world</h1>
</body>
@vneri
vneri / AjaxFetchWatcher.js
Created May 13, 2020 12:35
Script for counting open AJAX and fetch calls
// intercepts AJAX and fetch calls and provides a global status on open calls
var AjaxFetchWatcher = {};
AjaxFetchWatcher.countOfOpenRequests = 0;
AjaxFetchWatcher.stillOpen = function(){
return AjaxFetchWatcher.countOfOpenRequests > 0;
};
// intercept AJAX
@vneri
vneri / facebookAutoInviteLikers.js
Last active February 21, 2020 20:44
Auto Invite Facebook Post Likers, with load more and safety timer
// copy and paste this into the web console (open with F12)
// setup the text of the invitation and the "load more" button based on your language
// don't set the delay too low or you will be banned
// in test
var invitationButton = 'Einladen';
var loadMoreButton = 'Mehr anzeigen';
function Sleep(milliseconds) {
@vneri
vneri / getAllVariables.js
Last active August 4, 2024 07:49
How to get all variables and search through their values in JavaScript
function getAllVariables(){
var searchVarByValue = function(searchString){
var values = Object.keys(this.ValueToVar);
var findings = [];
for (var i=0; i< values.length; i++){
if (values[i] == undefined)
continue;
var position = values[i].toLowerCase().indexOf(searchString.toLowerCase());
if (position != -1){
findings.push({ 'variable': this.ValueToVar[values[i]], 'value' : values[i] });
@vneri
vneri / genCheckDigitUSPSTracking.js
Created June 25, 2018 12:22
JavaScript snippet for generating the checkdigit of an USPS tracking number
// using USPS Barcode Construct N04
// padding function, if not available
Object.prototype.pad = function(size) {
var targetHelper = String(this);
if (targetHelper.length<size){
targetHelper = Array((size - targetHelper.length)+1).join("0") + targetHelper;
}
return targetHelper;
}