Skip to content

Instantly share code, notes, and snippets.

View cocoabox's full-sized avatar

cocoabox cocoabox

View GitHub Profile
javascript:var style = document.createElement("style");style.appendChild(document.createTextNode(""));document.head.appendChild(style);style.sheet.insertRule(".Modal,.UnauthBanner{ display: none;height:1px !important;width:1px !important}", 0); style.sheet.insertRule(".noScroll{overflow:auto}",1);
@cocoabox
cocoabox / hide_twitter_ads.js
Last active May 23, 2016 05:07
hide ads from twitter (web only)
javascript:var style=document.createElement("style");document.head.appendChild(style);style.sheet.insertRule(
".promoted-tweet { display:none !important;height:0 !important;overflow:hidden !important}",0);
@cocoabox
cocoabox / twitter_hide_ads.js
Created May 31, 2016 03:39
hide promoted tweets from twitter / プロモツイートを全部非表示にするなにか
javascript:var style = document.createElement("style");document.head.appendChild(style);style.sheet.insertRule(".promoted-tweet { display: none !important; height: 0 !important; overflow: hidden !important }",0);
@cocoabox
cocoabox / detect_if_function_is_native.js
Last active July 14, 2016 13:21
JS でとある関数が nativeかどうか判定する
/**
* detect if function is native
* @param {function} func
* @return {boolean|null} returns true if func is native, false if not, or null if func is not a function
*/
var isNative = function(func){
return typeof func!=="function"
?null
:(null!==(""+func.toString()).match(/^\s*function\s*([^\s]+)\s*\{\s*\[native code\]\s*\}\s*$/));
}
@cocoabox
cocoabox / get_script_directory.sh
Last active July 14, 2016 13:20
sh で PHP の __FILE__ (現在実行中のスクリプト名)や __DIR__ (現在のスクリプトの所在ディレクトリ名)を取得する
#!/bin/sh
__FILE__=`readlink -f "$0" 2>/dev/null`
if [ -z "$__FILE__" ]; then
pushd `dirname "$0"` >/dev/null
__DIR__=`pwd`
popd >/dev/null
__FILE__="${__DIR__}/`basename "$0"`"
else
__DIR__=`dirname "$__FILE__"`
fi
@cocoabox
cocoabox / twitter_remove_ads.js
Last active August 4, 2016 13:23
ツイッター広告消し(使い方:以下のテキストをコピーして、ブラウザのツールバーに「新しいページ」→アドレス欄に貼り付ける)
javascript:var style = document.createElement("style");document.head.appendChild(style);for(var sel in {".promoted-tweet":0, ".DismissibleModule":0}){style.sheet.insertRule(sel+" { display: none !important; height: 0 !important; overflow: hidden !important }",0);}
@cocoabox
cocoabox / twitter_photo_grid.min.js
Last active September 24, 2016 15:49
This bookmarketlet collects all pics in the Twitter Timeline currently displayed (whether yours or not) and show them in a nice grid
javascript:!function(a,b,c){var d=function(){return b(".stream-item .AdaptiveMedia-photoContainer img")},e=function(c,d,e,f,g){c().length;f||(f=1e3),g||(g=1e3);var i=!0,k=[window.scrollX,window.scrollY],l=setInterval(function(){var f=c().length;i&&(window.scrollTo(0,a.body.scrollHeight),i=!1,setTimeout(function(){var g=c();f===g.length||g.length>d?(window.scrollTo(k[0],k[1]),clearInterval(l),"function"==typeof e&&e.apply(a,[])):b(document).trigger("uiShowMessage",{message:g.length+" 枚の画像が見つかりました...お待ち下さい( ˇωˇ )"}),i=!0},g))},f)},f=function(a){var c=window.open(),d=c.document,e=a();if(!c)return void alert("pop up ウィンドウは開けませんでした");!function(a,b){var c=b.createElement("style");b.head.appendChild(c);for(var d=0;d<a.length;++d)c.sheet.insertRule(a[d],d)}(["ul#grid_main { list-style: none; margin: 0; padding: 0 }","ul#grid_main > li { display:inline-block; width:9em; height:9em; overflow:hidden; margin:.15em; padding:0; border-radius:.2em }","ul#grid_main > li a { display: inline-block; height: 100%; width: 100% }"
@cocoabox
cocoabox / twitter_photo_grid.js
Last active March 6, 2018 12:00
twitter_photo_grid.js
(function(doc, $, console){
var images_wanted = window.prompt('現在の画面に表示される画像をグリッドでまとめます。(バグ報告は @cocoamatic まで)\n\n画像を何枚まで表示しますか?', '100');
images_wanted = parseInt(images_wanted);
if(! images_wanted) return;
var get_imgs = function(){ return $(".stream-item .AdaptiveMedia-photoContainer img") },
keep_scrolling = function(get_imgs, wanted_img_count, then_what, wait1, wait2) {
var img_len = get_imgs().length;
if (! wait1) wait1 = 5000;
if (! wait2) wait2 = 5000;
@cocoabox
cocoabox / mount_afp.sh
Last active February 9, 2018 15:05
mount AFP share with keychain password
#!/bin/sh
#
# e.g. mount_afp.sh 192.168.xx.xx files cocoa
#
SERVER="$1"
SHARE_NAME="$2"
USER_NAME="$3"
MOUNT_DIR="/Volumes/$SHARE_NAME"
if [ -z "$1" -o -z "$2" ]; then
echo "Usage: $0 <SERVER> <SHARE_NAME> [USER]\n"
@cocoabox
cocoabox / block_promoters_on_twitter.js
Last active November 1, 2016 18:19
block promoters on twitter
jQuery(".js-action-profile-promoted").parents(".tweet").each(function(){
var doc = jQuery(document),
me = jQuery(this),
tweet_id = me.data("tweet-id"),
content = me.find(".content"),
user_id = content.find(".stream-item-header a").data("user-id"),
screen_name = content.find(".stream-item-header .username b").text();
doc.trigger("uiBlockAction", {
screenName: screen_name,