Skip to content

Instantly share code, notes, and snippets.

@titangene
titangene / index.html
Last active January 5, 2018 16:40
Web × Arduino - Timeout (LED matrix)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Webduino Blockly Timeout Demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://webduino.io/components/webduino-js/dist/webduino-all.min.js"></script>
<script src="https://blockly.webduino.io/webduino-blockly.js"></script>
<script src="https://blockly.webduino.io/lib/runtime.min.js"></script>
@titangene
titangene / index.html
Last active January 5, 2018 16:40
Web × Arduino - Timeout (LED matrix, Google Voice)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Webduino Blockly Timeout Demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://webduino.io/components/webduino-js/dist/webduino-all.min.js"></script>
<script src="https://blockly.webduino.io/webduino-blockly.js"></script>
<script src="https://blockly.webduino.io/lib/runtime.min.js"></script>
@titangene
titangene / css-layout-hack.js
Last active June 19, 2022 00:37
css-layout-hack.js
// ref: https://gist.github.com/vcastroi/e0d296171842e74ad7d4eef7daf15df6
(function() {
const element = document.querySelector('#test-layout-styles');
if (element) {
document.head.removeChild(element);
} else {
const style = document.createElement('style');
style.id = 'test-layout-styles';
style.innerHTML = `
* {
@titangene
titangene / main.js
Last active April 9, 2021 12:34
Copy the name of the music that Spoifty is playing
(function() {
let title = document.querySelector('[data-testid=nowplaying-track-link]').textContent;
let singers = document.querySelector('[data-testid="track-info-artists"]').querySelectorAll('a');
let singerList = [...singers].map(x => x.textContent).join(' & ');
let textArea = document.createElement('textarea');
textArea.value = `${singerList} - ${title}`;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('Copy');
textArea.remove();
@titangene
titangene / main.js
Created October 27, 2019 03:46
Convert chrome tab link to Markdown link format and copy
(function() {
var title = document.title;
var url = location.href;
var textArea = document.createElement('textarea');
var copyText = `[${title}](${url})`;
textArea.value = copyText;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('Copy');
@titangene
titangene / main.js
Last active August 27, 2023 02:35
Remove the tracking query from the URL
(function() {
const params = [
'utm_term',
'utm_source',
'utm_medium',
'utm_content',
'utm_campaign',
'up_id',
'unique_k',
'timestamp',
@titangene
titangene / main.js
Last active March 11, 2024 04:00
copy YouTube subtitles
!(() => {
const captionElements = document.getElementsByClassName('segment-text style-scope ytd-transcript-segment-renderer');
const caption = [...captionElements]
.reduce((result, element) => result + element.innerText + ' ', '')
.replace(/[\.]/g, '.\n\n');
const textArea = document.createElement('textarea');
copyText = caption;
textArea.value = copyText;
document.body.appendChild(textArea);
@titangene
titangene / main.js
Created October 27, 2019 03:55
Convert Notion's note title and URL to Markdown link format and copy to clipboard
urlIconSelector = 'path[d*="M3.73333,3.86667 L7.46667"]';
urlIcons = document.querySelectorAll(urlIconSelector);
blocks = Array.prototype.map.call(urlIcons, icon => {
urlTitleNode = icon.parentNode.parentNode.nextSibling;
if (urlTitleNode.textContent === 'URL') {
urlValueNode = urlTitleNode.parentNode.parentNode.parentNode.nextSibling;
if (urlValueNode.textContent[0] !== 'Empty')
return urlValueNode.querySelector('span');
@titangene
titangene / main.js
Created October 27, 2019 03:58
Remove uncommonly used languages ​​from Google Translate in chrome extension
translateElement = document.getElementById('gtx-host');
translateContentElements = translateElement.shadowRoot.getElementById('bubble-content');
translateOptions = [...translateContentElements.querySelectorAll('option')];
languages = ['zh-CN', 'auto', 'en', 'ja'];
translateOptions.filter(option => !languages.includes(option.value))
.forEach(option => option.remove());
@titangene
titangene / main.py
Created October 30, 2019 17:25
Terminal progress bar with python
import time
import math
import os
rows, columns = os.popen('stty size', 'r').read().split()
# `[]` (2) + precent (5)
terminal_progress_fill = int(columns) - 7
current_progress = 0
while current_progress <= 100: