Skip to content

Instantly share code, notes, and snippets.

View syoichi's full-sized avatar

Syoichi Tsuyuhara syoichi

View GitHub Profile
@syoichi
syoichi / kusa5-2.user.js
Created October 15, 2015 10:51
ニコ動をHTML5で再生するスクリプト のチャンネル動画対応版を勝手に作った | FNB https://fushihara.org/blog/archives/3132 のソースコード
// ==UserScript==
// @name kusa5
// @namespace net.buhoho.kusa5
// @include http://www.nicovideo.jp/watch/*
// @version 1
// @grant none
// @description ニコ動html5表示
// ==/UserScript==
//localStorage.kusa5buffer : trueにするとバッファリングするようになる
@syoichi
syoichi / gist:8031106
Created December 18, 2013 22:39
ニコニコ動画の非公式APIの変更に暫定的に対応したnicovideo Thumbinfo popupのパッチ
@@ -1998,8 +1998,19 @@ var NicovideoContentGenerator = function() {
var p = $N('p', {'class': ClassNames.get('description')});
if(this.getData('parsedDescription') !== undefined)
p.innerHTML = this.getData('parsedDescription');
- else
- p.appendChild(this.getData('description').parseNicovideoDescription());
+ else {
+ let desc = this.getData('description').parseNicovideoDescription(),
+ links = desc.querySelectorAll('a'),
+ range = new Range();
@syoichi
syoichi / newTwitter.js
Last active December 22, 2015 17:28
Tombfixの新しいTwitter Modelの実装のWIP Patch。 https://github.com/tombfix/core/issues/60
Models.register(update({
name : 'Twitter Mod',
ICON : 'https://twitter.com/favicon.ico',
ORIGIN : 'https://twitter.com',
ACCOUT_URL : 'https://twitter.com/settings/account',
TWEET_API_URL : 'https://twitter.com/i/tweet',
UPLOAD_API_URL : 'https://upload.twitter.com/i/tweet/create_with_media.iframe',
STATUS_MAX_LENGTH : 140,
SHORT_URL_LENGTH : 22,
@syoichi
syoichi / taberareloo_code_reading.md
Last active December 18, 2015 14:19
Taberarelooのコードを読み、処理の流れを追う

私はTaberarelooのコードの全てを読んだ事はないので正確さに欠けますが書いてみます(ファイル名などはこのディレクトリより)。

polygon_planetさんのTomblooに関する意見と同じような意見ですが、まず、特定のサービスに関するExtractor(extractors.js)やModel(models.js)から読んでみるというのはどうでしょうか。これらの分野はUser Scriptなどと異なりTaberarelooの基本的な処理を構成する一部分なので何かと想像しやすいかもしれません(もちろんTaberarelooの処理の中心となるbackground.jsやcontent.jsから見ていくのも良いと思います)。 例として、私が関わった事があるものを挙げると、ExtractorについてはYouTube、ModelについてはGistが小さくてわかりやすいかもしれません。この単位であれば、パッチで実現できる規模でもある為、YungSangさんのパッチを読むというのも良いかもしれません。

正直言ってTumblrのExtractorとModelはもともと大きかったものが私のせいで複雑なものとなってしまっているので読むのはお勧めできません…。

読む際はChromeのデベロッパーツールでブレークポ

@syoichi
syoichi / gist:3747507
Last active February 6, 2023 16:26
Chrome拡張で自身のIDを取得する方法
// ref. http://stackoverflow.com/questions/12471316/what-is-the-best-way-to-retrieve-a-google-chrome-extension-id
// https://plus.google.com/100132233764003563318/posts/Ct39rw4DWGE
chrome.i18n.getMessage('@@extension_id');
// via https://github.com/Constellation/taberareloo/blob/d1299f052f14a3dfcb212eda0e3428c5f5c8a027/src/lib/content.js#L79
chrome.extension.getURL('').match(/chrome-extension:\/\/([^\/]+)\//)[1];
// Content Scriptでは動作しない
chrome.app.getDetails().id;
@syoichi
syoichi / gist:3366491
Last active November 14, 2016 15:33
nodeObserver - utility function for MutationObserver
/* example
nodeObserver(function log(info) {
console.log(info);
info.options.observer.disconnect();
}, {
target: document,
childList: true,
subtree: true,
addOnly: true
});
@syoichi
syoichi / sumally-add-via-link.user.js
Created August 2, 2012 01:10 — forked from swdyh/sumally-add-via-link.user.js
リストの表示モードに対応した。
@syoichi
syoichi / gist:3176714
Created July 25, 2012 15:15
Manifest Version 2のChrome拡張で、他の拡張のJavaScriptファイルをBackground ScriptからXHRで取得する方法と実行する方法

他の拡張のJavaScriptファイルを取得・実行できると、その拡張がインストールされていて有効になっている事がわかるExtension Messaging APIによる拡張間通信(受信側にEvent Listenerが設定されている場合)や、Management APIによっても知る事は可能。

検証環境はWindows 7 Home Premium SP1 64bit上のChrome 20.0.1132.57、Chromium 22.0.1217.0 (148295)。

XHRで取得する

取得するファイルを持つ拡張で、Manifestのweb_accessible_resourcesにファイルを登録しておく。

"web_accessible_resources": [
    "check.js"
@syoichi
syoichi / gist-logs.user.js
Created July 16, 2012 10:04 — forked from noromanba/gist-logs.user.js
show commit messages on Gist
// ==UserScript==
// @name gist logs
// @namsgpace https://www.hatena.ne.jp/noromanba/
// @description show commit messages on Gist
// @include https://gist.github.com/*
// @version 0.0.3
// @update 2012-07-18T21:18:13.437Z(GMT+09:00)
// @license WTFPL http://sam.zoy.org/wtfpl/ (Do What The Fuck You Want To Public License)
// @contributor satyr https://gist.github.com/107780
// @contributor saitamanodoruji https://gist.github.com/2653937
@syoichi
syoichi / gist:3120982
Created July 16, 2012 06:03
Chrome 20.0.1132.57のUser Scriptで利用できるGM関数とその実装
// ref. http://wiki.greasespot.net/Cross-browser_userscripting#Google_Chrome
// Comparison Table: https://github.com/scriptish/scriptish/wiki/Comparison-Table
// GM_setValue、GM_getValue、GM_registerMenuCommandは関数として呼び出せるものの、以下のようにChromeでは対応していない
/*
function () {
console.log("%s is not supported.", name);
}
*/