Skip to content

Instantly share code, notes, and snippets.

@moyashi
moyashi / amazonshare.js
Created February 16, 2020 11:32
AmazonからTwitterへのシェアの文面を整形するUserScript。Tampermonkeyで動作確認
// ==UserScript==
// @name AmazonShare
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fwww.amazon.co.jp*
// @grant none
// @require https://code.jquery.com/jquery-3.4.1.slim.min.js
// ==/UserScript==
@moyashi
moyashi / PrinterConnect.js
Last active February 7, 2020 05:58
OptoPrintでページ表示後に「Connect」ボタンを自動的に押すUserScript
// ==UserScript==
// @name PrinterConnect
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://192.168.1.33/
// @match http://192.168.1.32/
// @grant none
// ==/UserScript==
@moyashi
moyashi / BitBar-OctoPrint.rb
Last active February 5, 2020 01:52
OctoPrintを接続した3Dプリンターの動作状況をmacOS用アプリBitBarを使ってステータスバーに表示するRubyスクリプト
#!/usr/local/opt/ruby/bin/ruby
require 'open-uri'
require 'json'
require 'time'
OCTPRINT_IP = "192.168.1.33"
HEADER = "[C]"
begin
@moyashi
moyashi / eject_ms_dos_disk.applescript
Last active December 24, 2019 14:14
SDカード等のMS-DOSフォーマットのディスクをイジェクトするAppleScript
display notification "イジェクト処理開始"
set dl to {}
repeat with l in every paragraph of (do shell script "mount | grep -e 'msdos\\|exfat' | awk '{print $1}'")
set end of dl to (do shell script "diskutil info " & l & " | grep 'Volume Name:' | sed -e 's/Volume Name: //' | sed -e 's/^ *//'")
end repeat
if ((count of dl) is greater than 0) then
tell application "Finder"
toggleInstantHotspot = [[
tell application "System Events"
tell process "SystemUIServer"
tell menu bar 1
set menuBarItems to (every menu bar item whose description begins with "Wi-Fi")
if (count of menuBarItems) is greater than 0 then
set wifiMenuBarItem to item 1 of menuBarItems
click wifiMenuBarItem
--接続中か判定
set menuItemDisconnects to (every menu item of menu 1 of wifiMenuBarItem whose name ends with "との接続を解除")
;-------------------------------- 設定 ----------------------------------
TETHERING_SSIDS = {"iPhone 7 Plus", "iPhone 8 Plus"}
PASSWORD = "0000"
;--------------------------------------------------------------------------
DEBUG = true
;--------------------------------------------------------------------------
function setApplicationFirewall(arg)
hs.execute("echo " .. PASSWORD .. " | sudo -S /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate " .. arg)
end
@moyashi
moyashi / send_message.rb
Last active October 29, 2019 06:48
iOS 13.2で搭載されたメッセージ着信時の読み上げ機能(AirPods使用時限定)を活用するため、macOSのメッセージアプリから機械的にメッセージを送るスクリプト
#!/usr/bin/ruby
# iOS 13.2で搭載されたメッセージ着信時の読み上げ機能(AirPods使用時限定)を活用するため
# macOSのメッセージアプリから機械的にメッセージを送るスクリプト
# ■使い方
# 引数としてテキストを渡す(空白が入る場合はダブルクォーテーションで括る)
# send_message.rb "なんかテキスト"
#
# 標準入力としてテキストを渡す
--タイトル取得からの〜
tell application "Preview"
set n to name of window 1
--Window名から全体のページ数と現在のページ数をパースする
--それを監視しながらめくっていく
end tell
--全画面化
tell application "Preview" to activate
tell application "System Events"
@moyashi
moyashi / AliExpressNextPage.js
Last active February 9, 2019 08:48
AliExpressで次のページをめくるブックマークレット
javascript:var%20url%3DString(window.location.href)%3Bvar%20match%3Durl.match(%2F%26page%3D(%5Cd%2B)%2F)%3Bif(match%20!%3Dnull)%7Bvar%20page%3Dmatch%5B1%5D%3Bvar%20nextPage%3DString(Number(page)%2B%201)%3BnextUrl%3Durl.replace(match%5B0%5D%2Cmatch%5B0%5D.replace(page%2CnextPage))%3Bwindow.location%3DnextUrl%3B%7Delse%7Bwindow.location%3Durl%20%2B%20%22%26page%3D2%22%3B%7Dvoid(0);
@moyashi
moyashi / check_in_ubersuggest.js
Created January 30, 2019 02:15
今見ているページをUbersuggestで調査するブックマークレット
javascript:var%20h%3DString(location.hostname)%3Bif(h)%7Bvar%20prefix%3D%22https%3A%2F%2Fapp.neilpatel.com%2Fjp%2Ftraffic_analyzer%2Foverview%3Fdomain%3D%22%3Bwindow.open(prefix%20%2B%20encodeURIComponent(h)%2B%20%22%26country%3Djp%22)%3B%7Dvoid(0);