Skip to content

Instantly share code, notes, and snippets.


Joshua Tzucker joshuatz

View GitHub Profile
joshuatz / Android_WebView_Blocking.kt
Last active Jun 2, 2021
Example of how to intercept and block request with Android WebView
View Android_WebView_Blocking.kt
package com.joshuatz.webviewblock
import android.os.Bundle
import android.util.Log
import android.webkit.*
// Leave off www.
val BannedDomains: Array<String> = arrayOf("", "")
val BannedUrlPatterns: Array<Regex> = arrayOf(Regex("\\.taboola\\."))
View google-sheets-data-export-with-gas.js
* @file Mini-API to export data from a Google Sheet, created for fun
* @author Joshua Tzucker
* @see
* @license MIT
* @see (alternative)
// @ts-check
/// <reference path="/yarn-global/@types/google-apps-script/index.d.ts" />
joshuatz /
Last active Sep 9, 2020
Disable ChromeDriver messages to stdout with Selenium WebDriver & NodeJS

Make sure you have the minimum dependencies (e.g. you have run yarn add selenium-webdriver), and edit the file with your chromedriver bin info.

Here is a full writeup

joshuatz / vid_popper.js
Last active Aug 22, 2020
Video Popper for PiP - Override Disabled PiP Support
View vid_popper.js
let vidPopped = false;
document.querySelectorAll('video').forEach(vid => {
// Override disabling features
vid.disablePictureInPicture = false;
// Only pop right away if video is playing, or on Hulu
if ((!vid.paused || === 'content-video-player') && !vidPopped) {
if (typeof vid.requestPictureInPicture === 'function') {
.then(() => {
joshuatz / kasa.gas.js
Last active Mar 17, 2021
Google Apps Script Wrapper around Kasa API
View kasa.gas.js
* @file Google Apps Script Wrapper around Kasa API
* @license MIT
* @see
* @author Joshua Tzucker
* @see
* -
* -
// @ts-check
joshuatz / AndroidManifest.xml
Created Jan 4, 2020
TP-Link Kasa Android Manifest
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="" android:compileSdkVersion="29" android:compileSdkVersionCodename="10" package="com.tplink.kasa_android" platformBuildVersionCode="900" platformBuildVersionName="">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
joshuatz / PowerBI_JS_API_Reset_All_Slicers_Filters.js
Created May 17, 2019
Reset all Slicers (visual filter widgets) within a Power BI Javascript Embed
View PowerBI_JS_API_Reset_All_Slicers_Filters.js
async function resetAllSlicers() {
// This will target first embed on page, you can easily change
let report = powerbi.embeds[0];
let pages = await report.getPages();
for (let x = 0; x < pages.length; x++) {
let visuals = await pages[x].getVisuals();
for (let x = 0; x < visuals.length; x++) {
if (visuals[x].type === 'slicer') {
// Clear state, but wait before moving on to next one, since clearing a filter can have a cascade effect
try {
joshuatz / node_file_downloader.js
Created May 12, 2019
File downloader that you can call with Node and pass a URL, that has options for checking file integrity after download
View node_file_downloader.js
* @author Joshua Tzucker
* @file A reusable script to download a remote file, usually to have as a dependency, that for some reason can't be fetched through NPM
* File should be called with arguments:
* file_downloader.js remote_file local_folder_to_save_to [newFileName="foobar.js"][forceReDownload=FALSE] [fileHash="sha256-adsfasfd"]
* fileHash should be base64 - follow rule of SRI -
* Example:
joshuatz / restart_dropbox.bat
Created May 11, 2019
Restart the Dropbox client by running a Windows Batch Script. Searches in both Program Files directories for exe to start back up.
View restart_dropbox.bat
@echo off
REM # Find and kill the dropbox process
taskkill /FI "IMAGENAME eq Dropbox.exe" /F
REM # Wait a little
@echo on
echo "Please wait while restarting Dropbox"
@echo off
View Employee-Conditional-Tag-Loading.js
function httpFetchVanilla(url,method,callback,OPT_failCallback){method="string"==typeof method&&""!==method?method:"GET",callback="function"==typeof callback?callback:function(){},failCallback="function"==typeof OPT_failCallback?OPT_failCallback:function(){console.warn("httpFetchVanilla failed")};var t=new XMLHttpRequest;t.onreadystatechange=function(){4==t.readyState&&(200==t.status?callback(t.responseText):failCallback())},,url,!0),t.send()}
function setCookie(name, value, days) {
var d = new Date;
d.setTime(d.getTime() + 24*60*60*1000*days);
document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString();