updated vimperatorrc and bspwm
This commit is contained in:
parent
8f70970181
commit
2098417689
20 changed files with 248 additions and 4920 deletions
23
bspwm/bspwmrc
Executable file
23
bspwm/bspwmrc
Executable file
|
@ -0,0 +1,23 @@
|
|||
#! /bin/sh
|
||||
|
||||
bspc config border_width 1
|
||||
bspc config window_gap 14
|
||||
|
||||
bspc config split_ratio 0.60
|
||||
bspc config borderless_monocle true
|
||||
bspc config gapless_monocle true
|
||||
bspc config leaf_monocle true
|
||||
bspc config focus_by_distance true
|
||||
bspc config focus_follows_pointer true
|
||||
bspc config auto_alternate true
|
||||
bspc config ignore_ewmh_focus true
|
||||
bspc config remove_disabled_monitors true
|
||||
bspc config remove_unplugged_monitors true
|
||||
|
||||
bspc monitor -d I II III IV V VI VII VIII IX X
|
||||
|
||||
bspc rule -a Firefox desktop=^2
|
||||
bspc rule -a Chromium desktop=^3
|
||||
bspc rule -a Gimp desktop=^5 follow=on floating=on
|
||||
bspc rule -a feh desktop=^9
|
||||
bspc rule -a MPlayer floating=on
|
35
bspwm/panel
Executable file
35
bspwm/panel
Executable file
|
@ -0,0 +1,35 @@
|
|||
#! /bin/sh
|
||||
|
||||
if [ $(pgrep -cx panel) -gt 1 ] ; then
|
||||
printf "%s\n" "The panel is already running." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
|
||||
|
||||
PANEL_FIFO=/tmp/panel-fifo
|
||||
PANEL_HEIGHT=24
|
||||
PANEL_FONT_FAMILY="-*-lucidatypewriter-medium-*-*-*-26-*-*-*-*-*-*-*"
|
||||
|
||||
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
|
||||
mkfifo "$PANEL_FIFO"
|
||||
|
||||
bspc config top_padding $PANEL_HEIGHT
|
||||
bspc control --subscribe > "$PANEL_FIFO" &
|
||||
xtitle -sf 'T%s' > "$PANEL_FIFO" &
|
||||
while :; do
|
||||
_state=$(battery -f '%s')
|
||||
state=""
|
||||
[ $_state = "Discharging" ] && state="↓"
|
||||
[ $_state = "Charging" ] && state="↑"
|
||||
echo "SBAT $state$(battery -f '%i')%% $(clock -f '%a, %Y-%m-%d %H:%M')" > "$PANEL_FIFO"
|
||||
sleep 1
|
||||
done &
|
||||
#battery -sf 'Battery %s %i%%' > "$PANEL_FIFO" &
|
||||
#clock -sf '%a, Y-%m-%d %H:%M' > "$PANEL_FIFO" &
|
||||
|
||||
. $HOME/.config/bspwm/panel_colors
|
||||
|
||||
cat "$PANEL_FIFO" | panel_bar | lemonbar -g x$PANEL_HEIGHT -f "$PANEL_FONT_FAMILY" -F "$COLOR_FOREGROUND" -B "$COLOR_BACKGROUND" &
|
||||
|
||||
wait
|
74
bspwm/panel_bar
Executable file
74
bspwm/panel_bar
Executable file
|
@ -0,0 +1,74 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Example panel for LemonBoy's bar
|
||||
|
||||
. $HOME/.config/bspwm/panel_colors
|
||||
|
||||
num_mon=$(bspc query -M | wc -l)
|
||||
|
||||
while read -r line ; do
|
||||
case $line in
|
||||
S*)
|
||||
# clock output
|
||||
sys_infos="%{F$COLOR_STATUS_FG}%{B$COLOR_STATUS_BG} ${line#?} %{B-}%{F-}"
|
||||
;;
|
||||
T*)
|
||||
# xtitle output
|
||||
title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
|
||||
;;
|
||||
W*)
|
||||
# bspwm internal state
|
||||
wm_infos=""
|
||||
IFS=':'
|
||||
set -- ${line#?}
|
||||
while [ $# -gt 0 ] ; do
|
||||
item=$1
|
||||
name=${item#?}
|
||||
case $item in
|
||||
M*)
|
||||
# active monitor
|
||||
if [ $num_mon -gt 1 ] ; then
|
||||
wm_infos="$wm_infos %{F$COLOR_ACTIVE_MONITOR_FG}%{B$COLOR_ACTIVE_MONITOR_BG} ${name} %{B-}%{F-} "
|
||||
fi
|
||||
;;
|
||||
m*)
|
||||
# inactive monitor
|
||||
if [ $num_mon -gt 1 ] ; then
|
||||
wm_infos="$wm_infos %{F$COLOR_INACTIVE_MONITOR_FG}%{B$COLOR_INACTIVE_MONITOR_BG} ${name} %{B-}%{F-} "
|
||||
fi
|
||||
;;
|
||||
O*)
|
||||
# focused occupied desktop
|
||||
wm_infos="${wm_infos}%{F$COLOR_FOCUSED_OCCUPIED_FG}%{B$COLOR_FOCUSED_OCCUPIED_BG}%{U$COLOR_FOREGROUND}%{+u} ${name} %{-u}%{B-}%{F-}"
|
||||
;;
|
||||
F*)
|
||||
# focused free desktop
|
||||
wm_infos="${wm_infos}%{F$COLOR_FOCUSED_FREE_FG}%{B$COLOR_FOCUSED_FREE_BG}%{U$COLOR_FOREGROUND}%{+u} ${name} %{-u}%{B-}%{F-}"
|
||||
;;
|
||||
U*)
|
||||
# focused urgent desktop
|
||||
wm_infos="${wm_infos}%{F$COLOR_FOCUSED_URGENT_FG}%{B$COLOR_FOCUSED_URGENT_BG}%{U$COLOR_FOREGROUND}%{+u} ${name} %{-u}%{B-}%{F-}"
|
||||
;;
|
||||
o*)
|
||||
# occupied desktop
|
||||
wm_infos="${wm_infos}%{F$COLOR_OCCUPIED_FG}%{B$COLOR_OCCUPIED_BG} ${name} %{B-}%{F-}"
|
||||
;;
|
||||
f*)
|
||||
# free desktop
|
||||
wm_infos="${wm_infos}%{F$COLOR_FREE_FG}%{B$COLOR_FREE_BG} ${name} %{B-}%{F-}"
|
||||
;;
|
||||
u*)
|
||||
# urgent desktop
|
||||
wm_infos="${wm_infos}%{F$COLOR_URGENT_FG}%{B$COLOR_URGENT_BG} ${name} %{B-}%{F-}"
|
||||
;;
|
||||
L*)
|
||||
# layout
|
||||
wm_infos="$wm_infos %{F$COLOR_LAYOUT_FG}%{B$COLOR_LAYOUT_BG} ${name} %{B-}%{F-}"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
;;
|
||||
esac
|
||||
printf "%s\n" "%{l}${wm_infos}%{c}${title}%{r}${sys_infos}"
|
||||
done
|
24
bspwm/panel_colors
Normal file
24
bspwm/panel_colors
Normal file
|
@ -0,0 +1,24 @@
|
|||
COLOR_FOREGROUND='#FFA3A6AB'
|
||||
COLOR_BACKGROUND='#FF34322E'
|
||||
COLOR_ACTIVE_MONITOR_FG='#FF34322E'
|
||||
COLOR_ACTIVE_MONITOR_BG='#FF58C5F1'
|
||||
COLOR_INACTIVE_MONITOR_FG='#FF58C5F1'
|
||||
COLOR_INACTIVE_MONITOR_BG='#FF34322E'
|
||||
COLOR_FOCUSED_OCCUPIED_FG='#FFF6F9FF'
|
||||
COLOR_FOCUSED_OCCUPIED_BG='#FF5C5955'
|
||||
COLOR_FOCUSED_FREE_FG='#FFF6F9FF'
|
||||
COLOR_FOCUSED_FREE_BG='#FF6D561C'
|
||||
COLOR_FOCUSED_URGENT_FG='#FF34322E'
|
||||
COLOR_FOCUSED_URGENT_BG='#FFF9A299'
|
||||
COLOR_OCCUPIED_FG='#FFA3A6AB'
|
||||
COLOR_OCCUPIED_BG='#FF34322E'
|
||||
COLOR_FREE_FG='#FF6F7277'
|
||||
COLOR_FREE_BG='#FF34322E'
|
||||
COLOR_URGENT_FG='#FFF9A299'
|
||||
COLOR_URGENT_BG='#FF34322E'
|
||||
COLOR_LAYOUT_FG='#FFA3A6AB'
|
||||
COLOR_LAYOUT_BG='#FF34322E'
|
||||
COLOR_TITLE_FG='#FFA3A6AB'
|
||||
COLOR_TITLE_BG='#FF34322E'
|
||||
COLOR_STATUS_FG='#FFA3A6AB'
|
||||
COLOR_STATUS_BG='#FF34322E'
|
|
@ -1,749 +0,0 @@
|
|||
/*** BEGIN LICENSE BLOCK {{{
|
||||
Copyright (c) 2008 suVene<suvene@zeromemory.info>
|
||||
Copyright (c) 2008-2011 anekos<anekos@snca.net>
|
||||
|
||||
distributable under the terms of an MIT-style license.
|
||||
http://www.opensource.jp/licenses/mit-license.html
|
||||
}}} END LICENSE BLOCK ***/
|
||||
// PLUGIN_INFO//{{{
|
||||
var PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>libly(filename _libly.js)</name>
|
||||
<description>Vimperator plugins library?</description>
|
||||
<description lang="ja">適当なライブラリっぽいものたち。</description>
|
||||
<author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
|
||||
<author mail="anekos@snca.net" homepage="http://snca.net/">anekos</author>
|
||||
<license>MIT</license>
|
||||
<version>0.1.38</version>
|
||||
<minVersion>2.3pre</minVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/_libly.js</updateURL>
|
||||
<detail><![CDATA[
|
||||
== Objects ==
|
||||
- liberator.plugins.libly.$U
|
||||
- liberator.plugins.libly.Request
|
||||
- liberator.plugins.libly.Response
|
||||
- liberator.plugins.libly.Wedata
|
||||
|
||||
== Logger ==
|
||||
getLogger(prefix):
|
||||
log(msg, level), echo(msg, flg), echoerr(msg)
|
||||
のメソッドを持つ logger インスタンスを取得します。
|
||||
ログの書式は prefix + ': ' + yyyy/MM/dd + msg となります。
|
||||
|
||||
== Object Utility ==
|
||||
extend(dst, src):
|
||||
オブジェクトを拡張します。
|
||||
A(iterable):
|
||||
オブジェクトを配列にします。
|
||||
around(obj, name, func, autoRestore):
|
||||
obj がもつ name 関数を、func に置き換えます。
|
||||
func は
|
||||
function (next, args) {...}
|
||||
という形で呼ばれます。
|
||||
next はオリジナルの関数を呼び出すための関数、
|
||||
args はオリジナルの引数列です。
|
||||
通常、next には引数を渡す必要はありません。
|
||||
(任意の引数を渡したい場合は配列で渡します。)
|
||||
また、autoRestore が真であれば、プラグインの再ロードなどで around が再実行されたときに、関数の置き換え前にオリジナル状態に書き戻します。
|
||||
(多重に置き換えられなくなるので、auto_source.js などを使ったプラグイン開発で便利です)
|
||||
返値は以下のオブジェクトです
|
||||
>||
|
||||
{
|
||||
original: オリジナルの関数
|
||||
current: 現在の関数
|
||||
restore: 元に戻すための関数
|
||||
}
|
||||
||<
|
||||
bind(obj, func):
|
||||
func に obj を bind します。
|
||||
func内からは this で obj が参照できるようになります。
|
||||
eval(text):
|
||||
Sandbox による、window.eval を極力利用するようにします。
|
||||
Snadbox が利用できない場合は、unsafe な window の eval が直接利用されます。
|
||||
evalJson(str, toRemove):
|
||||
str を decode します。
|
||||
toRemove が true の場合、文字列の前後を1文字削除します。
|
||||
"(key:value)" 形式の場合などに true を指定して下さい。
|
||||
dateFormat(dtm, fmt):
|
||||
Date型インスタンスを、指定されたフォーマットで文字列に変換します。
|
||||
fmt を省略した場合、"%y/%M/%d %h:%m:%s" となります。
|
||||
runnable(generator):
|
||||
gererator を実行し、再帰的に resume する為の引数を渡します。
|
||||
|
||||
== Browser ==
|
||||
getSelectedString:
|
||||
window の選択文字列を返却します。
|
||||
getUserAndPassword(hostname, formSubmitURL, username):
|
||||
login-manager から [username, password] を取得します。
|
||||
引数の username が省略された場合、検索された 1件目を返却します。
|
||||
データが存在しない場合は、null を返却します。
|
||||
|
||||
== System ==
|
||||
readDirectory(path, fileter, func):
|
||||
path で指定したディレクトリから、filter で指定された正規表現に match する場合、
|
||||
func をファイル名を引数にコールバックします。
|
||||
filter は Function を指定することも可能です。
|
||||
|
||||
== HTML, XML, DOM, E4X ==
|
||||
pathToURL(a, baseURL, doc):
|
||||
相対パスを絶対パスに変換します。
|
||||
getHTMLFragment(html):
|
||||
<html>※1</html>
|
||||
※1 の文字列を取得します。
|
||||
stripTags(str, tags):
|
||||
str から tags で指定されたタグを取り除いて返却します。
|
||||
tags は文字列、または配列で指定して下さい。
|
||||
createHTMLDocument(str, xmlns):
|
||||
引数 str より、HTMLFragment を作成します。
|
||||
getFirstNodeFromXPath(xpath, context):
|
||||
xpath を評価しオブジェクトをを返却します。
|
||||
getNodesFromXPath(xpath, context, callback, thisObj):
|
||||
xpath を評価し snapshot の配列を返却します。
|
||||
xmlSerialize(xml):
|
||||
xml を文字列化します。
|
||||
xmlToDom(node, doc, nodes):
|
||||
for vimperator1.2.
|
||||
@see vimperator2.0pre util.
|
||||
getElementPosition(elem):
|
||||
elem の offset を返却します。
|
||||
return {top: 0, left: 0}
|
||||
toStyleText(style):
|
||||
スタイルが格納されているオブジェクトを
|
||||
>||
|
||||
position: fixed;
|
||||
left: 10px;
|
||||
||<
|
||||
のような文字列に変換します。
|
||||
|
||||
== Object Request ==
|
||||
Request(url, headers, options):
|
||||
コンストラクタ
|
||||
url:
|
||||
HTTPリクエスト先のURL
|
||||
headers:
|
||||
以下のようにHTTPヘッダの値を指定できる(省略可)
|
||||
>||
|
||||
{
|
||||
'Referer' : 'http://example.com/'
|
||||
}
|
||||
||<
|
||||
以下の値はデフォルトで設定される('Content-type'はPOST時のみ)
|
||||
>||
|
||||
{
|
||||
'Accept': 'text/javascript, application/javascript, text/html, application/xhtml+xml, application/xml, text/xml, */*;q=0.1',
|
||||
'Content-type': 'application/x-www-form-urlencoded; charset=' + options.encodingの値
|
||||
}
|
||||
||<
|
||||
|
||||
options:
|
||||
オプションとして以下のようなオブジェクトを指定できる(省略可)
|
||||
asynchronous:
|
||||
true: 非同期モード/false: 同期モード(デフォルト:true)
|
||||
encoding:
|
||||
エンコーディング(デフォルト: 'UTF-8')
|
||||
username:
|
||||
BASIC認証時のuser名
|
||||
password:
|
||||
BASIC認証時のパスワード
|
||||
postBody:
|
||||
POSTメソッドにより送信するbody
|
||||
addEventListener(name, func):
|
||||
イベントリスナを登録する。
|
||||
name:
|
||||
'success':
|
||||
成功時
|
||||
'failure':
|
||||
失敗を表すステータスコードが返ってきた時
|
||||
'exception':
|
||||
例外発生時
|
||||
func:
|
||||
イベント発火時の処理
|
||||
引数として以下Responseオブジェクトが渡される
|
||||
get():
|
||||
GETメソッドによりHTTPリクエストを発行する。
|
||||
post():
|
||||
POSTメソッドによりHTTPリクエストを発行する。
|
||||
|
||||
== Object Response ==
|
||||
HTTPレスポンスを表すオブジェクト
|
||||
req:
|
||||
レスポンスと対となるRequestオブジェクト
|
||||
doc:
|
||||
レスポンスから生成されたHTMLDocumentオブジェクト
|
||||
isSuccess():
|
||||
ステータスコードが成功を表していればtrue、失敗であればfalse
|
||||
getStatus():
|
||||
ステータスコードを取得する
|
||||
getStatusText():
|
||||
ステータを表す文字列を取得する
|
||||
getHTMLDocument(xpath, xmlns, ignoreTags, callback, thisObj):
|
||||
レスポンスからHTMLDocumentオブジェクトを生成し、xpath を評価した結果の snapshot の配列を返す
|
||||
|
||||
== Object Wedata ==
|
||||
~/vimperator/info/profile_name/plugins-libly-wedata-?????
|
||||
に store されます。
|
||||
getItems(expire, itemCallback, finalCallback):
|
||||
インスタンス作成時に指定した dbname から、item を読込みます。
|
||||
=== TODO ===
|
||||
clearCache:
|
||||
wedata 読込み成功したら、強制的にキャッシュと置き換えるの作って!
|
||||
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
//}}}
|
||||
//if (!liberator.plugins.libly) {
|
||||
|
||||
liberator.plugins.libly = {};
|
||||
var libly = liberator.plugins.libly;
|
||||
|
||||
// XXX for backward compatibillity
|
||||
function fixEventName(name) {
|
||||
return name.replace(/^on/, '').toLowerCase();
|
||||
}
|
||||
|
||||
libly.$U = {//{{{
|
||||
// Logger {{{
|
||||
getLogger: function(prefix) {
|
||||
return new function() {
|
||||
this.log = function(msg, level) {
|
||||
if (typeof msg == 'object') msg = util.objectToString(msg);
|
||||
liberator.log(libly.$U.dateFormat(new Date()) + ': ' + (prefix || '') + ': ' + msg, (level || 0));
|
||||
};
|
||||
this.echo = function(msg, flg) {
|
||||
flg = flg || commandline.FORCE_MULTILINE;
|
||||
// this.log(msg);
|
||||
liberator.echo(msg, flg);
|
||||
};
|
||||
this.echoerr = function(msg) {
|
||||
this.log('error: ' + msg);
|
||||
liberator.echoerr(msg);
|
||||
};
|
||||
}
|
||||
},
|
||||
// }}}
|
||||
// Object Utility {{{
|
||||
extend: function(dst, src) {
|
||||
for (let prop in src)
|
||||
dst[prop] = src[prop];
|
||||
return dst;
|
||||
},
|
||||
A: function(iterable) {
|
||||
var ret = [];
|
||||
if (!iterable) return ret;
|
||||
if (typeof iterable == 'string') return [iterable];
|
||||
if (!(typeof iterable == 'function' && iterable == '[object NodeList]') &&
|
||||
iterable.toArray) return iterable.toArray();
|
||||
if (typeof iterable.length != 'undefined') {
|
||||
for (let i = 0, len = iterable.length; i < len; ret.push(iterable[i++]));
|
||||
} else {
|
||||
for each (let item in iterable) ret.push(item);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
around: (function () {
|
||||
function getPluginPath () {
|
||||
let pluginPath;
|
||||
Error('hoge').stack.split(/\n/).some(
|
||||
function (s)
|
||||
let (m = s.match(/^(?:\(\))?@chrome:\/\/liberator\/content\/liberator\.js -> (.+):\d+$/))
|
||||
(m && (pluginPath = m[1].replace(/\?.*$/, '')))
|
||||
);
|
||||
return pluginPath;
|
||||
}
|
||||
|
||||
let restores = {};
|
||||
|
||||
return function (obj, name, func, autoRestore) {
|
||||
let original;
|
||||
let restore = function () obj[name] = original;
|
||||
if (autoRestore) {
|
||||
let pluginPath = getPluginPath();
|
||||
if (pluginPath) {
|
||||
restores[pluginPath] =
|
||||
(restores[pluginPath] || []).filter(
|
||||
function (res) (
|
||||
res.object != obj ||
|
||||
res.name != name ||
|
||||
(res.restore() && false)
|
||||
)
|
||||
);
|
||||
restores[pluginPath].push({
|
||||
object: obj,
|
||||
name: name,
|
||||
restore: restore
|
||||
});
|
||||
} else {
|
||||
liberator.echoerr('getPluginPath failed');
|
||||
}
|
||||
}
|
||||
original = obj[name];
|
||||
let current = obj[name] = function () {
|
||||
let self = this, args = arguments;
|
||||
return func.call(self, function (_args) original.apply(self, _args || args), args);
|
||||
};
|
||||
libly.$U.extend(current, {original: original && original.original || original, restore: restore});
|
||||
return libly.$U.extend({
|
||||
original: original,
|
||||
current: current,
|
||||
restore: restore
|
||||
}, [original, current]);
|
||||
};
|
||||
})(),
|
||||
bind: function(obj, func) {
|
||||
return function() {
|
||||
return func.apply(obj, arguments);
|
||||
}
|
||||
},
|
||||
eval: function(text) {
|
||||
var fnc = window.eval;
|
||||
var sandbox;
|
||||
try {
|
||||
sandbox = new Components.utils.Sandbox("about:blank");
|
||||
if (Components.utils.evalInSandbox('true', sandbox) === true) {
|
||||
fnc = function(text) { return Components.utils.evalInSandbox(text, sandbox); };
|
||||
}
|
||||
} catch (e) { liberator.log('warning: _libly.js is working with unsafe sandbox.'); }
|
||||
|
||||
return fnc(text);
|
||||
},
|
||||
evalJson: function(str, toRemove) {
|
||||
var json;
|
||||
try {
|
||||
json = Components.classes['@mozilla.org/dom/json;1'].getService(Components.interfaces.nsIJSON);
|
||||
if (toRemove) str = str.substring(1, str.length - 1);
|
||||
return json.decode(str);
|
||||
} catch (e) { return null; }
|
||||
},
|
||||
dateFormat: function(dtm, fmt) {
|
||||
var d = {
|
||||
y: dtm.getFullYear(),
|
||||
M: dtm.getMonth() + 1,
|
||||
d: dtm.getDate(),
|
||||
h: dtm.getHours(),
|
||||
m: dtm.getMinutes(),
|
||||
s: dtm.getSeconds(),
|
||||
'%': '%'
|
||||
};
|
||||
for (let [n, v] in Iterator(d)) {
|
||||
if (v < 10)
|
||||
d[n] = '0' + v;
|
||||
}
|
||||
return (fmt || '%y/%M/%d %h:%m:%s').replace(/%([yMdhms%])/g, function (_, n) d[n]);
|
||||
},
|
||||
/**
|
||||
* example)
|
||||
* $U.runnable(function(resume) {
|
||||
* // execute asynchronous function.
|
||||
* // goto next yield;
|
||||
* var val = yield setTimeout(function() { resume('value!'), 1000) });
|
||||
* alert(val); // value!
|
||||
* yield;
|
||||
* });
|
||||
*/
|
||||
runnable: function(generator) {
|
||||
var it = generator(function(value) {
|
||||
try { it.send(value); } catch (e) {}
|
||||
});
|
||||
it.next();
|
||||
},
|
||||
// }}}
|
||||
// Browser {{{
|
||||
getSelectedString: function() {
|
||||
return (new XPCNativeWrapper(window.content.window)).getSelection().toString();
|
||||
},
|
||||
getUserAndPassword: function(hostname, formSubmitURL, username) {
|
||||
var passwordManager, logins;
|
||||
try {
|
||||
passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
|
||||
logins = passwordManager.findLogins({}, hostname, formSubmitURL, null);
|
||||
if (logins.length) {
|
||||
if (username) {
|
||||
for (let i = 0, len = logins.lengh; i < len; i++) {
|
||||
if (logins[i].username == username)
|
||||
return [logins[i].username, logins[i].password]
|
||||
}
|
||||
liberator.log(this.dateFormat(new Date()) +': [getUserAndPassword] username notfound');
|
||||
//throw 'username notfound.';
|
||||
return [];
|
||||
} else {
|
||||
return [logins[0].username, logins[0].password];
|
||||
}
|
||||
} else {
|
||||
liberator.log(this.dateFormat(new Date()) + ': [getUserAndPassword] account notfound');
|
||||
return [];
|
||||
}
|
||||
} catch (e) {
|
||||
liberator.log(this.dateFormat(new Date()) + ': [getUserAndPassword] error: ' + e, 0);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
// }}}
|
||||
// System {{{
|
||||
readDirectory: function(path, filter, func) {
|
||||
var d = io.File(path);
|
||||
if (d.exists() && d.isDirectory()) {
|
||||
let enm = d.directoryEntries;
|
||||
let flg = false;
|
||||
while (enm.hasMoreElements()) {
|
||||
let item = enm.getNext();
|
||||
item.QueryInterface(Components.interfaces.nsIFile);
|
||||
flg = false;
|
||||
if (typeof filter == 'string') {
|
||||
if ((new RegExp(filter)).test(item.leafName)) flg = true;
|
||||
} else if (typeof filter == 'function') {
|
||||
flg = filter(item);
|
||||
}
|
||||
if (flg) func(item);
|
||||
}
|
||||
}
|
||||
},
|
||||
// }}}
|
||||
// HTML, XML, DOM, E4X {{{
|
||||
pathToURL: function(a, baseURL, doc) {
|
||||
if (!a) return '';
|
||||
var XHTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
var XML_NS = "http://www.w3.org/XML/1998/namespace";
|
||||
//var path = (a.href || a.getAttribute('src') || a.action || a.value || a);
|
||||
var path = (a.getAttribute('href') || a.getAttribute('src') || a.action || a.value || a);
|
||||
if (/^https?:\/\//.test(path)) return path;
|
||||
var link = (doc || window.content.documtent).createElementNS(XHTML_NS, 'a');
|
||||
link.setAttributeNS(XML_NS, 'xml:base', baseURL);
|
||||
link.href = path;
|
||||
return link.href;
|
||||
},
|
||||
getHTMLFragment: function(html) {
|
||||
if (!html) return html;
|
||||
return html.replace(/^[\s\S]*?<html(?:[ \t\n\r][^>]*)?>|<\/html[ \t\r\n]*>[\S\s]*$/ig, '');
|
||||
},
|
||||
stripTags: function(str, tags) {
|
||||
var ignoreTags = '(?:' + [].concat(tags).join('|') + ')';
|
||||
return str.replace(new RegExp('<' + ignoreTags + '(?:[ \\t\\n\\r][^>]*|/)?>([\\S\\s]*?)<\/' + ignoreTags + '[ \\t\\r\\n]*>', 'ig'), '');
|
||||
},
|
||||
createHTMLDocument: function(str, xmlns, doc) {
|
||||
let root = document.createElementNS("http://www.w3.org/1999/xhtml", "html");
|
||||
let uhService = Cc["@mozilla.org/feed-unescapehtml;1"].getService(Ci.nsIScriptableUnescapeHTML);
|
||||
let text = str.replace(/^[\s\S]*?<body([ \t\n\r][^>]*)?>[\s]*|<\/body[ \t\r\n]*>[\S\s]*$/ig, '');
|
||||
let fragment = uhService.parseFragment(text, false, null, root);
|
||||
let doctype = document.implementation.createDocumentType('html', '-//W3C//DTD HTML 4.01//EN', 'http://www.w3.org/TR/html4/strict.dtd');
|
||||
let htmlFragment = document.implementation.createDocument(null, 'html', doctype);
|
||||
htmlFragment.documentElement.appendChild(htmlFragment.importNode(fragment,true));
|
||||
return htmlFragment;
|
||||
/* うまく動いていない場合はこちらに戻してください
|
||||
doc = doc || window.content.document;
|
||||
var htmlFragment = doc.implementation.createDocument(null, 'html', null);
|
||||
var range = doc.createRange();
|
||||
range.setStartAfter(doc.body);
|
||||
htmlFragment.documentElement.appendChild(htmlFragment.importNode(range.createContextualFragment(str), true));
|
||||
return htmlFragment;
|
||||
*/
|
||||
},
|
||||
getFirstNodeFromXPath: function(xpath, context) {
|
||||
if (!xpath) return null;
|
||||
context = context || window.content.document;
|
||||
var result = (context.ownerDocument || context).evaluate(xpath, context, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
||||
return result.singleNodeValue || null;
|
||||
},
|
||||
getNodesFromXPath: function(xpath, context, callback, thisObj) {
|
||||
var ret = [];
|
||||
if (!xpath) return ret;
|
||||
context = context || window.content.document;
|
||||
var nodesSnapshot = (context.ownerDocument || context).evaluate(xpath, context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
|
||||
for (let i = 0, l = nodesSnapshot.snapshotLength; i < l; i++) {
|
||||
if (typeof callback == 'function') callback.call(thisObj, nodesSnapshot.snapshotItem(i), i);
|
||||
ret.push(nodesSnapshot.snapshotItem(i));
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
xmlSerialize: function(xml) {
|
||||
try {
|
||||
return (new XMLSerializer()).serializeToString(xml)
|
||||
.replace(/<!--(?:[^-]|-(?!->))*-->/g, '')
|
||||
.replace(/<\s*\/?\s*\w+/g, function(all) all.toLowerCase());
|
||||
} catch (e) { return '' }
|
||||
},
|
||||
xmlToDom: function xmlToDom(node, doc, nodes)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
switch (node.nodeKind())
|
||||
{
|
||||
case "text":
|
||||
return doc.createTextNode(node);
|
||||
case "element":
|
||||
let domnode = doc.createElementNS(node.namespace(), node.localName());
|
||||
for each (let attr in node.@*)
|
||||
domnode.setAttributeNS(attr.name() == "highlight" ? NS.uri : attr.namespace(), attr.name(), String(attr));
|
||||
for each (let child in node.*)
|
||||
domnode.appendChild(arguments.callee(child, doc, nodes));
|
||||
if (nodes && node.@key)
|
||||
nodes[node.@key] = domnode;
|
||||
return domnode;
|
||||
}
|
||||
},
|
||||
getElementPosition: function(elem) {
|
||||
var offsetTrail = elem;
|
||||
var offsetLeft = 0;
|
||||
var offsetTop = 0;
|
||||
while (offsetTrail) {
|
||||
offsetLeft += offsetTrail.offsetLeft;
|
||||
offsetTop += offsetTrail.offsetTop;
|
||||
offsetTrail = offsetTrail.offsetParent;
|
||||
}
|
||||
offsetTop = offsetTop || null;
|
||||
offsetLeft = offsetLeft || null;
|
||||
return {top: offsetTop, left: offsetLeft};
|
||||
},
|
||||
toStyleText: function(style) {
|
||||
var result = '';
|
||||
for (let name in style) {
|
||||
result += name.replace(/[A-Z]/g, function (c) ('-' + c.toLowerCase())) +
|
||||
': ' +
|
||||
style[name] +
|
||||
';\n';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// }}}
|
||||
};
|
||||
//}}}
|
||||
|
||||
libly.Request = function() {//{{{
|
||||
this.initialize.apply(this, arguments);
|
||||
};
|
||||
libly.Request.EVENTS = ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
|
||||
libly.Request.requestCount = 0;
|
||||
libly.Request.prototype = {
|
||||
initialize: function(url, headers, options) {
|
||||
this.url = url;
|
||||
this.headers = headers || {};
|
||||
this.options = libly.$U.extend({
|
||||
asynchronous: true,
|
||||
encoding: 'UTF-8'
|
||||
}, options || {});
|
||||
this.observers = {};
|
||||
},
|
||||
addEventListener: function(name, func) {
|
||||
name = fixEventName(name);
|
||||
try {
|
||||
if (typeof this.observers[name] == 'undefined') this.observers[name] = [];
|
||||
this.observers[name].push(func);
|
||||
} catch (e) {
|
||||
if (!this.fireEvent('exception', new libly.Response(this), e)) throw e;
|
||||
}
|
||||
},
|
||||
fireEvent: function(name, args, asynchronous) {
|
||||
name = fixEventName(name);
|
||||
if (!(this.observers[name] instanceof Array)) return false;
|
||||
this.observers[name].forEach(function(event) {
|
||||
if (asynchronous) {
|
||||
setTimeout(event, 10, args);
|
||||
} else {
|
||||
event(args);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
},
|
||||
_complete: false,
|
||||
_request: function(method) {
|
||||
|
||||
try {
|
||||
libly.Request.requestCount++;
|
||||
|
||||
this.method = method;
|
||||
this.transport = new XMLHttpRequest();
|
||||
this.transport.open(method, this.url, this.options.asynchronous, this.options.username, this.options.password);
|
||||
|
||||
var stateChangeException;
|
||||
this.transport.onreadystatechange = libly.$U.bind(this, function () {
|
||||
try {
|
||||
this._onStateChange();
|
||||
} catch (e) {
|
||||
stateChangeException = e;
|
||||
}
|
||||
});
|
||||
this.setRequestHeaders();
|
||||
this.transport.overrideMimeType(this.options.mimetype || 'text/html; charset=' + this.options.encoding);
|
||||
|
||||
this.body = this.method == 'POST' ? this.options.postBody : null;
|
||||
|
||||
this.transport.send(this.body);
|
||||
|
||||
if (!this.options.asynchronous && stateChangeException) throw stateChangeException;
|
||||
|
||||
// Force Firefox to handle ready state 4 for synchronous requests
|
||||
if (!this.options.asynchronous && this.transport.overrideMimeType)
|
||||
this._onStateChange();
|
||||
|
||||
} catch (e) {
|
||||
if (!this.fireEvent('exception', new libly.Response(this), e)) throw e;
|
||||
}
|
||||
},
|
||||
_onStateChange: function() {
|
||||
var readyState = this.transport.readyState;
|
||||
if (readyState > 1 && !(readyState == 4 && this._complete))
|
||||
this.respondToReadyState(this.transport.readyState);
|
||||
},
|
||||
getStatus: function() {
|
||||
try {
|
||||
return this.transport.status || 0;
|
||||
} catch (e) { return 0; }
|
||||
},
|
||||
isSuccess: function() {
|
||||
var status = this.getStatus();
|
||||
return !status || (status >= 200 && status < 300);
|
||||
},
|
||||
respondToReadyState: function(readyState) {
|
||||
var state = libly.Request.EVENTS[readyState];
|
||||
var res = new libly.Response(this);
|
||||
|
||||
if (state == 'Complete') {
|
||||
libly.Request.requestCount--;
|
||||
try {
|
||||
this._complete = true;
|
||||
this.fireEvent(this.isSuccess() ? 'success' : 'failure', res, this.options.asynchronous);
|
||||
} catch (e) {
|
||||
if (!this.fireEvent('exception', res, e)) throw e;
|
||||
}
|
||||
}
|
||||
},
|
||||
setRequestHeaders: function() {
|
||||
var headers = {
|
||||
'Accept': 'text/javascript, application/javascript, text/html, application/xhtml+xml, application/xml, text/xml, */*;q=0.1'
|
||||
};
|
||||
|
||||
if (this.method == 'POST') {
|
||||
headers['Content-type'] = 'application/x-www-form-urlencoded' +
|
||||
(this.options.encoding ? '; charset=' + this.options.encoding : '');
|
||||
|
||||
if (this.transport.overrideMimeType) {
|
||||
let year = parseInt((navigator.userAgent.match(/\bGecko\/(\d{4})/) || [0, 2005])[1], 10);
|
||||
if (0 < year && year < 2005)
|
||||
headers['Connection'] = 'close';
|
||||
}
|
||||
}
|
||||
|
||||
for (let key in this.headers)
|
||||
if (this.headers.hasOwnProperty(key)) headers[key] = this.headers[key];
|
||||
|
||||
for (let name in headers)
|
||||
this.transport.setRequestHeader(name, headers[name]);
|
||||
},
|
||||
get: function() {
|
||||
this._request('GET');
|
||||
},
|
||||
post: function() {
|
||||
this._request('POST');
|
||||
}
|
||||
};//}}}
|
||||
|
||||
libly.Response = function() {//{{{
|
||||
this.initialize.apply(this, arguments);
|
||||
};
|
||||
libly.Response.prototype = {
|
||||
initialize: function(req) {
|
||||
this.req = req;
|
||||
this.transport = req.transport;
|
||||
this.isSuccess = req.isSuccess;
|
||||
this.readyState = this.transport.readyState;
|
||||
|
||||
if (this.readyState == 4) {
|
||||
this.status = this.getStatus();
|
||||
this.statusText = this.getStatusText();
|
||||
this.responseText = (this.transport.responseText == null) ? '' : this.transport.responseText;
|
||||
this.responseXML = this.transport.responseXML;
|
||||
}
|
||||
|
||||
this.doc = null;
|
||||
this.htmlFragmentstr = '';
|
||||
},
|
||||
status: 0,
|
||||
statusText: '',
|
||||
getStatus: libly.Request.prototype.getStatus,
|
||||
getStatusText: function() {
|
||||
try {
|
||||
return this.transport.statusText || '';
|
||||
} catch (e) { return ''; }
|
||||
},
|
||||
getHTMLDocument: function(xpath, xmlns, ignoreTags, callback, thisObj) {
|
||||
if (!this.doc) {
|
||||
//if (doc.documentElement.nodeName != 'HTML') {
|
||||
// return new DOMParser().parseFromString(str, 'application/xhtml+xml');
|
||||
//}
|
||||
this.htmlFragmentstr = libly.$U.getHTMLFragment(this.responseText);
|
||||
this.htmlStripScriptFragmentstr = libly.$U.stripTags(this.htmlFragmentstr, ignoreTags);
|
||||
this.doc = libly.$U.createHTMLDocument(this.htmlStripScriptFragmentstr, xmlns);
|
||||
}
|
||||
if (!xpath) xpath = '//*';
|
||||
return libly.$U.getNodesFromXPath(xpath, this.doc, callback, thisObj);
|
||||
}
|
||||
};
|
||||
//}}}
|
||||
|
||||
libly.Wedata = function(dbname) { // {{{
|
||||
this.initialize.apply(this, arguments);
|
||||
};
|
||||
libly.Wedata.prototype = {
|
||||
initialize: function(dbname) {
|
||||
this.HOST_NAME = 'http://wedata.net/';
|
||||
this.dbname = dbname;
|
||||
this.logger = libly.$U.getLogger('libly.Wedata');
|
||||
},
|
||||
getItems: function(expire, itemCallback, finalCallback) {
|
||||
|
||||
var logger = this.logger;
|
||||
var STORE_KEY = 'plugins-libly-wedata-' + encodeURIComponent(this.dbname) + '-items';
|
||||
var store = storage.newMap(STORE_KEY, {store: true});
|
||||
var cache = store && store.get('data');
|
||||
|
||||
if (store && cache && new Date(store.get('expire')) > new Date()) {
|
||||
logger.log('return cache. ');
|
||||
cache.forEach(function(item) { if (typeof itemCallback == 'function') itemCallback(item); });
|
||||
if (typeof finalCallback == 'function')
|
||||
finalCallback(true, cache);
|
||||
return;
|
||||
}
|
||||
|
||||
expire = expire || 0;
|
||||
|
||||
function errDispatcher(msg, cache) {
|
||||
if (cache) {
|
||||
logger.log('return cache. -> ' + msg);
|
||||
cache.forEach(function(item) { if (typeof itemCallback == 'function') itemCallback(item); });
|
||||
if (typeof finalCallback == 'function')
|
||||
finalCallback(true, cache);
|
||||
} else {
|
||||
logger.log(msg + ': cache notfound.');
|
||||
if (typeof finalCallback == 'function')
|
||||
finalCallback(false, msg);
|
||||
}
|
||||
}
|
||||
|
||||
var req = new libly.Request(this.HOST_NAME + 'databases/' + encodeURIComponent(this.dbname) + '/items.json');
|
||||
req.addEventListener('success', libly.$U.bind(this, function(res) {
|
||||
var text = res.responseText;
|
||||
if (!text) {
|
||||
errDispatcher('response is null.', cache);
|
||||
return;
|
||||
}
|
||||
var json = libly.$U.evalJson(text);
|
||||
if (!json) {
|
||||
errDispatcher('failed eval json.', cache);
|
||||
return;
|
||||
}
|
||||
logger.log('success get wedata.');
|
||||
store.set('expire', new Date(new Date().getTime() + expire).toString());
|
||||
store.set('data', json);
|
||||
store.save();
|
||||
json.forEach(function(item) { if (typeof itemCallback == 'function') itemCallback(item); });
|
||||
if (typeof finalCallback == 'function')
|
||||
finalCallback(true, json);
|
||||
}));
|
||||
req.addEventListener('failure', function() errDispatcher('onFailure', cache));
|
||||
req.addEventListener('exception', function() errDispatcher('onException', cache));
|
||||
req.get();
|
||||
}
|
||||
};
|
||||
//}}}
|
||||
|
||||
//}
|
||||
// vim: set fdm=marker sw=4 ts=4 sts=0 et:
|
||||
|
|
@ -1,476 +0,0 @@
|
|||
/* {{{
|
||||
###################################################################################
|
||||
# SL 部分は、Takahito Yagami さんの著作権物です。 #
|
||||
# JavaScriptでSLを走らせる「SL.JS」を作りました ::: creazy photograph #
|
||||
# http://creazy.net/2008/02/sl_js.html #
|
||||
###################################################################################
|
||||
}}} */
|
||||
|
||||
// PLUGIN_INFO {{{
|
||||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>Alert</name>
|
||||
<name lang="ja">アラート</name>
|
||||
<description>Displays an alert after the specified time.</description>
|
||||
<description lang="ja">指定時間後にアラートダイアログを出したりする。タイマー。</description>
|
||||
<version>1.01</version>
|
||||
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
|
||||
<minVersion>2.0pre</minVersion>
|
||||
<maxVersion>2.0pre</maxVersion>
|
||||
<detail lang="ja"><![CDATA[
|
||||
かなり変梃な仕様です。
|
||||
== Command ==
|
||||
:alert [<TIME> | <METHOD> | <MESSAGE>] ...:
|
||||
<TIME> 分後に、<MESSAGE> を表示する。
|
||||
<METHOD> でアラート方法を指定する。
|
||||
引数はどのような順番でも良い。
|
||||
e.g.:
|
||||
>||
|
||||
:alert 1.5 ugh
|
||||
:alert -meow=4 -alert 2.0 This is Message!
|
||||
:alert This 1.5 -meow=4 -pokimon=10 is Message!
|
||||
||<
|
||||
== Methods ==
|
||||
:-alert:
|
||||
標準的な JS の alert
|
||||
:-gunsou:
|
||||
恐ろしい軍曹が出現
|
||||
:-pokimon:
|
||||
ピッカー!
|
||||
使用には注意してください!
|
||||
:-meow:
|
||||
"みゃお"
|
||||
:-quit:
|
||||
Firefox を終了する
|
||||
== Thanks ==
|
||||
SL 部分は下記のスクリプトからパクリました!
|
||||
プラグインから呼べるように多少書き換えています。
|
||||
JavaScriptでSLを走らせる「SL.JS」を作りました ::: creazy photograph
|
||||
http://creazy.net/2008/02/sl_js.html
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
// }}}
|
||||
|
||||
(function () {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SL - copyright (c) Takahito Yagami
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
let sl = function (next) {
|
||||
var document = content.document;
|
||||
/**
|
||||
* SL.JS
|
||||
*
|
||||
* # execute bookmarklet below
|
||||
* javascript:(function(){var d=document,sl_open,sl_run,sl_close,s=d.createElement('script');s.charset='UTF-8';s.src='http://labs.creazy.net/sl/bookmarklet.js';d.body.appendChild(s)})();
|
||||
*
|
||||
* @author Takahito Yagami <takahito.yagami[at]gmail[dot]com> (a.k.a yager)
|
||||
* @version v1.0.0 2008/02/16
|
||||
*/
|
||||
(function(){
|
||||
//------------------------------------------------------------
|
||||
// Setting (You can chage options in this block)
|
||||
//------------------------------------------------------------
|
||||
var sl_speed = 100;
|
||||
var sl_pitch = 15;
|
||||
var sl_tx_color = "#FFFFFF";
|
||||
var sl_bg_color = "#000000";
|
||||
//------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------
|
||||
// SL Parts
|
||||
//------------------------------------------------------------
|
||||
var sl_steam = [];
|
||||
sl_steam[0]
|
||||
=" (@@) ( ) (@) ( ) @@ () @ O @ O @<br>"
|
||||
+" ( )<br>"
|
||||
+" (@@@@)<br>"
|
||||
+" ( )<br>"
|
||||
+"<br>"
|
||||
+" (@@@)<br>";
|
||||
sl_steam[1]
|
||||
=" ( ) (@@) ( ) (@) () @@ O @ O @ O<br>"
|
||||
+" (@@@)<br>"
|
||||
+" ( )<br>"
|
||||
+" (@@@@)<br>"
|
||||
+"<br>"
|
||||
+" ( )<br>";
|
||||
|
||||
var sl_body
|
||||
=" ==== ________ ___________ <br>"
|
||||
+" _D _| |_______/ \\__I_I_____===__|_________| <br>"
|
||||
+" |(_)--- | H\\________/ | | =|___ ___| _________________ <br>"
|
||||
+" / | | H | | | | ||_| |_|| _| \\_____A <br>"
|
||||
+" | | | H |__--------------------| [___] | =| | <br>"
|
||||
+" | ________|___H__/__|_____/[][]~\\_______| | -| | <br>"
|
||||
+" |/ | |-----------I_____I [][] [] D |=======|____|________________________|_ <br>";
|
||||
|
||||
var sl_wheels = [];
|
||||
sl_wheels[0]
|
||||
="__/ =| o |=-O=====O=====O=====O \\ ____Y___________|__|__________________________|_ <br>"
|
||||
+" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
|
||||
+" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
|
||||
sl_wheels[1]
|
||||
="__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ <br>"
|
||||
+" |/-=|___|=O=====O=====O=====O |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
|
||||
+" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
|
||||
sl_wheels[2]
|
||||
="__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ <br>"
|
||||
+" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
|
||||
+" \\_/ \\O=====O=====O=====O_/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
|
||||
sl_wheels[3]
|
||||
="__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ <br>"
|
||||
+" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
|
||||
+" \\_/ \\_O=====O=====O=====O/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
|
||||
sl_wheels[4]
|
||||
="__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__|__________________________|_ <br>"
|
||||
+" |/-=|___|= O=====O=====O=====O|_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
|
||||
+" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
|
||||
sl_wheels[5]
|
||||
="__/ =| o |=-~O=====O=====O=====O\\ ____Y___________|__|__________________________|_ <br>"
|
||||
+" |/-=|___|= || || || |_____/~\\___/ |_D__D__D_| |_D__D__D_| <br>"
|
||||
+" \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ \\_/ \\_/ \\_/ \\_/ <br>";
|
||||
|
||||
sl_steam[0] = sl_steam[0].replace(/ /g,' ');
|
||||
sl_steam[1] = sl_steam[1].replace(/ /g,' ');
|
||||
sl_body = sl_body.replace(/ /g,' ');
|
||||
sl_wheels[0] = sl_wheels[0].replace(/ /g,' ');
|
||||
sl_wheels[1] = sl_wheels[1].replace(/ /g,' ');
|
||||
sl_wheels[2] = sl_wheels[2].replace(/ /g,' ');
|
||||
sl_wheels[3] = sl_wheels[3].replace(/ /g,' ');
|
||||
sl_wheels[4] = sl_wheels[4].replace(/ /g,' ');
|
||||
sl_wheels[5] = sl_wheels[5].replace(/ /g,' ');
|
||||
|
||||
var sl_patterns = [];
|
||||
sl_patterns[0] = sl_steam[0] + sl_body + sl_wheels[0];
|
||||
sl_patterns[1] = sl_steam[0] + sl_body + sl_wheels[1];
|
||||
sl_patterns[2] = sl_steam[0] + sl_body + sl_wheels[2];
|
||||
sl_patterns[3] = sl_steam[1] + sl_body + sl_wheels[3];
|
||||
sl_patterns[4] = sl_steam[1] + sl_body + sl_wheels[4];
|
||||
sl_patterns[5] = sl_steam[1] + sl_body + sl_wheels[5];
|
||||
|
||||
//------------------------------------------------------------
|
||||
// SL Initialize
|
||||
//------------------------------------------------------------
|
||||
var sl_counter = 0;
|
||||
var sl_position = 0;
|
||||
var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
||||
if (window.opera||document.layers) {
|
||||
var windowWidth = window.innerWidth;
|
||||
} else if (document.all) {
|
||||
var windowWidth = document.body.clientWidth;
|
||||
} else if(document.getElementById){
|
||||
var windowWidth = window.innerWidth;
|
||||
}
|
||||
var sl_style_base
|
||||
='display: block;'
|
||||
+'position: absolute;'
|
||||
+'text-align: left;'
|
||||
+'overflow: visible;'
|
||||
+'white-space: pre;'
|
||||
+'font: 12px/12px monospace;';
|
||||
|
||||
var sl_style_main
|
||||
=sl_style_base
|
||||
+'top: '+(scrollTop+100)+'px;'
|
||||
+'left: '+windowWidth+'px;'
|
||||
+'padding: 20px;'
|
||||
+'z-index: 999;'
|
||||
+'color: '+sl_tx_color+';';
|
||||
|
||||
document.body.innerHTML += '<div id="__sl_main__" style="'+sl_style_main+'">'+sl_patterns[0]+'</div>';
|
||||
|
||||
var sl_w = document.getElementById("__sl_main__").clientWidth;
|
||||
var sl_h = document.getElementById("__sl_main__").clientHeight;
|
||||
|
||||
var sl_style_background
|
||||
=sl_style_base
|
||||
+'top: '+(scrollTop+100)+'px;'
|
||||
+'left: 0px;'
|
||||
+'width: '+windowWidth+'px;'
|
||||
+'height: '+sl_h+'px;'
|
||||
+'z-index: 998;'
|
||||
+'background-color: '+sl_bg_color+';'
|
||||
+'filter: alpha(opacity=0);'
|
||||
+'-moz-opacity: 0.0;'
|
||||
+'opacity: 0.0;';
|
||||
|
||||
document.body.innerHTML += '<div id="__sl_background__" style="'+sl_style_background+'"><br /></div>';
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Actions
|
||||
//------------------------------------------------------------
|
||||
var sl_bg_counter = 0;
|
||||
|
||||
/**
|
||||
* sl_open (gradually open background)
|
||||
*/
|
||||
sl_open = function() {
|
||||
var oid = "__sl_background__";
|
||||
var op = sl_bg_counter;
|
||||
var ua = navigator.userAgent
|
||||
document.getElementById(oid).style.filter = 'alpha(opacity=' + (op * 10) + ')';
|
||||
document.getElementById(oid).style.MozOpacity = op / 10;
|
||||
document.getElementById(oid).style.opacity = op / 10;
|
||||
if ( sl_bg_counter < 8 ) {
|
||||
sl_bg_counter++;
|
||||
setTimeout('sl_open()',100);
|
||||
} else {
|
||||
sl_run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* sl_run (move a train)
|
||||
*/
|
||||
sl_run = function() {
|
||||
document.getElementById("__sl_main__").innerHTML = sl_patterns[sl_counter];
|
||||
document.getElementById("__sl_main__").style.left = windowWidth - sl_position + "px";
|
||||
if ( sl_counter < 5 ) {
|
||||
sl_counter++;
|
||||
} else {
|
||||
sl_counter = 0;
|
||||
}
|
||||
sl_position += sl_pitch;
|
||||
if ( sl_w + (windowWidth - sl_position) < 0 ) {
|
||||
sl_counter = 0;
|
||||
sl_position = 0;
|
||||
document.body.removeChild(document.getElementById("__sl_main__"));
|
||||
sl_close();
|
||||
} else {
|
||||
setTimeout('sl_run()',sl_speed);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sl_close (gradually close background)
|
||||
*/
|
||||
sl_close = function() {
|
||||
var oid = "__sl_background__";
|
||||
var op = sl_bg_counter;
|
||||
var ua = navigator.userAgent
|
||||
document.getElementById(oid).style.filter = 'alpha(opacity=' + (op * 10) + ')';
|
||||
document.getElementById(oid).style.MozOpacity = op / 10;
|
||||
document.getElementById(oid).style.opacity = op / 10;
|
||||
if ( sl_bg_counter > 0 ) {
|
||||
sl_bg_counter--;
|
||||
setTimeout('sl_close()',100);
|
||||
} else {
|
||||
next();
|
||||
document.body.removeChild(document.getElementById(oid));
|
||||
}
|
||||
}
|
||||
|
||||
// start actions !
|
||||
sl_open();
|
||||
|
||||
})();
|
||||
};
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// END OF SL
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
let gv = liberator.globalVariables;
|
||||
|
||||
let defaults = {
|
||||
methods: (gv.alert_default_methods || 'alert').split(/\W+/),
|
||||
time: parseFloat(gv.alert_default_time || '3'),
|
||||
message: gv.alert_default_message || 'Time out!',
|
||||
};
|
||||
|
||||
let maxMeow = parseInt(liberator.globalVariables.alert_mex_meow || '60', 10);
|
||||
|
||||
let sound = Cc["@mozilla.org/sound;1"].createInstance(Ci.nsISound);
|
||||
sound.init();
|
||||
|
||||
let gunsou = 'data:image/gif;base64,'+
|
||||
'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'+
|
||||
'J04QDASAfeIRAgA7';
|
||||
|
||||
function nop ()
|
||||
undefined;
|
||||
|
||||
function singularize (fs, msg) {
|
||||
if (!fs.length)
|
||||
return nop;
|
||||
let [f, arg] = fs[0];
|
||||
return function () {
|
||||
f(singularize(fs.slice(1), msg), msg, arg);
|
||||
};
|
||||
}
|
||||
|
||||
let alertMethods = {
|
||||
alert: function (next, msg) {
|
||||
window.alert(msg);
|
||||
next();
|
||||
},
|
||||
pokimon: function (next, msg, arg) {
|
||||
let times = parseInt(arg || '10', 10);
|
||||
let colors = ['red', 'blue', 'yellow'];
|
||||
let elem = content.document.body;
|
||||
let indicator = elem.appendChild(elem.ownerDocument.createElement('div'));
|
||||
let rect = elem.getBoundingClientRect();
|
||||
indicator.id = 'nyantoro-element-indicator';
|
||||
let style = 'background-color: ' + colors[0] + ';' +
|
||||
'opacity: 0.5; z-index: 999;' +
|
||||
'position: fixed;' +
|
||||
'top: ' + 0 + 'px;' +
|
||||
'height: ' + content.innerHeight + 'px;' +
|
||||
'left: ' + 0 + 'px;' +
|
||||
'width: ' + content.innerWidth + 'px';
|
||||
indicator.setAttribute('style', style);
|
||||
let (count = 0) {
|
||||
let handle = setInterval(
|
||||
function () {
|
||||
if (count++ < times) {
|
||||
indicator.style.backgroundColor = colors[count % colors.length];
|
||||
} else {
|
||||
clearInterval(handle);
|
||||
elem.removeChild(indicator);
|
||||
next();
|
||||
}
|
||||
},
|
||||
100
|
||||
);
|
||||
}
|
||||
},
|
||||
gunsou: function (next, msg, arg) {
|
||||
let sleep = parseFloat(arg || 3) * 1000;
|
||||
let sz = innerWidth / msg.length / 1.5;
|
||||
liberator.echo(
|
||||
<div style="background: white; color: black;">
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src={gunsou}/></td>
|
||||
<td style={"font-size: " + sz + "px; white-space: nowrap;"}>{msg}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
setTimeout(next, sleep);
|
||||
},
|
||||
meow: function (next, msg, arg) {
|
||||
let times = Math.min(parseInt(arg || '3', 10), maxMeow);
|
||||
let handle = setInterval(
|
||||
function () {
|
||||
if (times--) {
|
||||
sound.play(makeURI('http://www.kurinton.net/~snca/files/meow.wav'));
|
||||
} else {
|
||||
clearInterval(handle);
|
||||
next();
|
||||
}
|
||||
},
|
||||
1000
|
||||
);
|
||||
},
|
||||
quit: function (next, msg) {
|
||||
liberator.quit(true);
|
||||
next();
|
||||
},
|
||||
SL: function (next, msg) {
|
||||
sl(next);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
defaults.methods = defaults.methods.map(
|
||||
function (it) {
|
||||
let [_, name, arg] = it.match(/^-?(\w+)(?:=(.*))?$/);
|
||||
return [alertMethods[name] || nop, arg];
|
||||
}
|
||||
);
|
||||
|
||||
commands.addUserCommand(
|
||||
['alert'],
|
||||
'Timer alert (:alert [<TIME> | <METHOD> | <MESSAGE>] ...)',
|
||||
function (args) {
|
||||
let methods = [], time = null, message = '';
|
||||
args.forEach(function (v) {
|
||||
let m, f;
|
||||
if ((m = v.match(/^-(\w+)(?:=(.*))?$/)) && (f = alertMethods[m[1]]))
|
||||
methods.push([f, m[2]]);
|
||||
else if (!time && v.match(/^\d+(\.\d+)?$/))
|
||||
time = parseFloat(v);
|
||||
else
|
||||
message += ' ' + v;
|
||||
});
|
||||
if (!message)
|
||||
message = defaults.message;
|
||||
if (!time)
|
||||
time = defaults.time;
|
||||
if (!methods.length)
|
||||
methods = defaults.methods;
|
||||
setTimeout(singularize(methods, message), time * 60 * 1000);
|
||||
},
|
||||
{
|
||||
argCount: '*',
|
||||
completer: function (context, args) {
|
||||
context.title = ['method', 'Description'];
|
||||
context.completions = [
|
||||
['-alert', 'JS alert'],
|
||||
['-gunsou', 'Spawn horrible sergeant'],
|
||||
['-meow', 'Meow'],
|
||||
['-pokimon', 'Like a electric mouse'],
|
||||
['-quit', 'Quit firefox'],
|
||||
['-SL', 'Run SL'],
|
||||
];
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
})();
|
||||
|
||||
// vim:sw=2 ts=2 et si fdm=marker:
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>appendAnchor</name>
|
||||
<description>append anchors to texts look like url.</description>
|
||||
<description lang="ja">リンク中の URL っぽいテキストにアンカーをつける。</description>
|
||||
<version>0.4.7</version>
|
||||
<author>SAKAI, Kazuaki</author>
|
||||
<minVersion>2.0pre</minVersion>
|
||||
<maxVersion>2.4</maxVersion>
|
||||
<detail><![CDATA[
|
||||
== Commands ==
|
||||
:anc:
|
||||
Append anchors.
|
||||
== GlobalVariables ==
|
||||
g:auto_append_anchor:
|
||||
Execute ":anc" automatically when Vimperator shows the hints.
|
||||
g:auto_append_anchor_once:
|
||||
Just first once.
|
||||
]]></detail>
|
||||
<detail lang="ja"><![CDATA[
|
||||
== Commands ==
|
||||
:anc:
|
||||
アンカーを付加する。
|
||||
== GlobalVariables ==
|
||||
g:auto_append_anchor:
|
||||
Vimperator がヒントを表示するときに自動的に ":anc" する。
|
||||
g:auto_append_anchor_once:
|
||||
最初の一回だけ。
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
|
||||
(function(){
|
||||
|
||||
// settings ---
|
||||
// "ACEILMPRSTXY" is result of below code.
|
||||
// Array.prototype.uniq = function() this.reduceRight( function (a, b) (a[0] === b || a.unshift(b), a), []);
|
||||
// [ 'TITLE', 'STYLE', 'SCRIPT', 'TEXTAREA', 'XMP', 'A', ].join('').split('').sort().uniq().join('');
|
||||
const xpathQueryPlainText = '/descendant::*[not(contains(" TITLE STYLE SCRIPT TEXTAREA XMP A ", concat(" ", translate(local-name(), "aceilmprstxy", "ACEILMPRSTXY"), " ")))]/child::text()';
|
||||
const regexpLikeURL = new RegExp("(h?ttps?|ftp):/+([a-zA-Z0-9][-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+[-_~*(a-zA-Z0-9;/?@&=+$%#])");
|
||||
|
||||
// process global variable
|
||||
if (stringToBoolean(liberator.globalVariables.auto_append_anchor, false)) {
|
||||
let originalHintsShow = liberator.modules.hints.show;
|
||||
let once = stringToBoolean(liberator.globalVariables.auto_append_anchor_once, true);
|
||||
hints.show = function () {
|
||||
if (!(once && content.document.anchor_appended)) {
|
||||
content.document.anchor_appended = true;
|
||||
liberator.execute('anc');
|
||||
}
|
||||
originalHintsShow.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// register command
|
||||
liberator.modules.commands.addUserCommand(['anc'], 'append anchors to texts look like url',
|
||||
function(arg) {
|
||||
function append() {
|
||||
let result = 0;
|
||||
const doc = window.content.document;
|
||||
const range = doc.createRange();
|
||||
|
||||
let nodes = util.evaluateXPath(xpathQueryPlainText);
|
||||
for (let node in nodes) {
|
||||
while (node) {
|
||||
range.selectNode(node)
|
||||
|
||||
// search string like URL
|
||||
let start = range.toString().search(regexpLikeURL);
|
||||
// go to next node when there is nothing look like URL in current node
|
||||
if (!(start > -1)) break;
|
||||
|
||||
result++;
|
||||
|
||||
// build URL
|
||||
let scheme = RegExp.$1, host = RegExp.$2, lastMatch = RegExp.lastMatch;
|
||||
if (/^ttps?$/.test(scheme)) scheme = 'h' + scheme;
|
||||
let href = scheme + '://' + host;
|
||||
|
||||
// reset range
|
||||
range.setStart(node, start);
|
||||
range.setEnd(node, start + lastMatch.length);
|
||||
|
||||
// build anchor element
|
||||
let anchor = doc.createElement('a');
|
||||
anchor.setAttribute('href', href);
|
||||
range.surroundContents(anchor);
|
||||
|
||||
// insert
|
||||
range.insertNode(anchor);
|
||||
|
||||
// iterate
|
||||
node = node.nextSibling.nextSibling.nextSibling;
|
||||
}
|
||||
}
|
||||
range.detach();
|
||||
return result;
|
||||
}
|
||||
for (let i = 0; i < 20 && append(); i++)
|
||||
;
|
||||
},
|
||||
{},
|
||||
true
|
||||
);
|
||||
|
||||
// stuff function
|
||||
function stringToBoolean(str, defaultValue) {
|
||||
if (typeof str === 'number')
|
||||
str = str.toString();
|
||||
return !str ? (defaultValue ? true : false)
|
||||
: str.toLowerCase() === 'false' ? false
|
||||
: /^\d+$/.test(str) ? (parseInt(str) ? true : false)
|
||||
: true;
|
||||
}
|
||||
|
||||
})();
|
|
@ -1,177 +0,0 @@
|
|||
/* NEW BSD LICENSE {{{
|
||||
Copyright (c) 2008-2010, anekos.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. The names of the authors may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
###################################################################################
|
||||
# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license #
|
||||
# に参考になる日本語訳がありますが、有効なのは上記英文となります。 #
|
||||
###################################################################################
|
||||
|
||||
}}} */
|
||||
|
||||
// PLUGIN_INFO {{{
|
||||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>bit.ly</name>
|
||||
<description>Get short alias by bit.ly and j.mp</description>
|
||||
<description lang="ja">bit.ly や j.mp で短縮URLを得る</description>
|
||||
<version>2.1.2</version>
|
||||
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
|
||||
<license>new BSD License (Please read the source code comments of this plugin)</license>
|
||||
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/bitly.js</updateURL>
|
||||
<minVersion>2.0pre</minVersion>
|
||||
<detail><![CDATA[
|
||||
== Commands ==
|
||||
:bitly [<URL>]
|
||||
Copy to clipboard.
|
||||
:jmp [<URL>]
|
||||
Copy to clipboard.
|
||||
== Require ==
|
||||
bit.ly API Key
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
// }}}
|
||||
|
||||
|
||||
(function () {
|
||||
|
||||
const Realm = 'API Key for bit.ly (bitly.js)';
|
||||
const HostName = 'http://api.bit.ly';
|
||||
const ApiUrl = 'http://api.bit.ly/v3';
|
||||
const PasswordManager = Cc['@mozilla.org/login-manager;1'].getService(Ci.nsILoginManager);
|
||||
const LoginInfo =
|
||||
new Components.Constructor(
|
||||
'@mozilla.org/login-manager/loginInfo;1',
|
||||
Ci.nsILoginInfo,
|
||||
'init'
|
||||
);
|
||||
|
||||
function getAuth () {
|
||||
let count = {};
|
||||
let logins = PasswordManager.findLogins(count, HostName, null, Realm);
|
||||
if (logins.length)
|
||||
return logins[0];
|
||||
}
|
||||
|
||||
function setupAuth (callback) {
|
||||
liberator.open('http://bit.ly/a/your_api_key', liberator.NEW_TAB);
|
||||
commandline.input(
|
||||
'Login name for bit.ly: ',
|
||||
function (username) {
|
||||
commandline.input(
|
||||
'API Key: ',
|
||||
function (apiKey) {
|
||||
let login = LoginInfo(HostName, null, Realm, username, apiKey, '', '');
|
||||
PasswordManager.addLogin(login);
|
||||
callback();
|
||||
},
|
||||
{
|
||||
default: let (e = content.document.querySelector('#bitly_api_key')) (e ? e.value : '')
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function shorten (url, domain, command, callback) {
|
||||
function fixResponseText (s)
|
||||
s.trim();
|
||||
|
||||
liberator.log(arguments);
|
||||
function get () {
|
||||
let req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function () {
|
||||
if (req.readyState != 4)
|
||||
return;
|
||||
if (req.status == 200)
|
||||
return callback && callback(fixResponseText(req.responseText), req);
|
||||
else
|
||||
return liberator.echoerr(req.statusText);
|
||||
};
|
||||
let requestUri =
|
||||
ApiUrl + '/' + (command || 'shorten') + '?' +
|
||||
'apiKey=' + auth.password + '&' +
|
||||
'login=' + auth.username + '&' +
|
||||
(command !== 'expand' ? 'uri=' : 'shortUrl=') + encodeURIComponent(url) + '&' +
|
||||
'domain=' + (domain || 'bit.ly') + '&' +
|
||||
'format=txt';
|
||||
req.open('GET', requestUri, callback);
|
||||
req.send(null);
|
||||
return !callback && fixResponseText(req.responseText);
|
||||
}
|
||||
|
||||
if (!url)
|
||||
url = buffer.URL;
|
||||
|
||||
let auth = getAuth();
|
||||
|
||||
if (auth)
|
||||
return get();
|
||||
|
||||
if (callback) {
|
||||
let args = Array.slice(arguments);
|
||||
setupAuth(function () shorten.apply(this, args));
|
||||
} else {
|
||||
liberator.echoerr('Not found API Key!! Try :bitly command, before use.');
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
['jmp', 'j.mp'],
|
||||
['bitly', 'bit.ly'],
|
||||
].forEach(function ([name, domain]) {
|
||||
commands.addUserCommand(
|
||||
[name],
|
||||
'Copy ' + domain + ' url',
|
||||
function (args) {
|
||||
let url = args.literalArg ? util.stringToURLArray(args.literalArg)[0] : buffer.URL;
|
||||
let cmd = args['-expand'] ? 'expand' : 'shorten';
|
||||
|
||||
shorten(url, domain, cmd, function (short) {
|
||||
util.copyToClipboard(short);
|
||||
liberator.echo(short + ' <= ' + url);
|
||||
});
|
||||
},
|
||||
{
|
||||
literal: 0,
|
||||
options: [
|
||||
[['-expand', '-e'], commands.OPTION_NOARG]
|
||||
],
|
||||
completer: function (context) {
|
||||
context.completions = [
|
||||
[buffer.URL, 'Current URL']
|
||||
];
|
||||
context.fork('URL', 0, context, completion.url);
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
__context__[name] = function (url, cmd, callback) shorten(url, domain, cmd, callback);
|
||||
});
|
||||
|
||||
__context__.get = shorten;
|
||||
})();
|
|
@ -1,123 +0,0 @@
|
|||
/**
|
||||
* bookmarklet wo command ni suru plugin
|
||||
*
|
||||
* @author halt feits <halt.feits@gmail.com>
|
||||
* @version 0.6.4
|
||||
*/
|
||||
|
||||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>{NAME}</name>
|
||||
<description>convert bookmarklets to commands</description>
|
||||
<description lang="ja">ブックマークレットをコマンドにする</description>
|
||||
<author mail="halt.feits@gmail.com">halt feits</author>
|
||||
<version>0.6.6</version>
|
||||
<minVersion>2.0pre</minVersion>
|
||||
<maxVersion>2.1pre</maxVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/commandBookmarklet.js</updateURL>
|
||||
<detail><![CDATA[
|
||||
== SYNOPSIS ==
|
||||
This plugin automatically converts bookmarklets to valid commands for Vimperator.
|
||||
|
||||
== COMMAND ==
|
||||
Nothing built-in command, but each bookmarklets convert to commands that start with "bml".
|
||||
|
||||
== EXAMPLE ==
|
||||
"Hatena-Bookmark" -> bmlhatena-bookmark
|
||||
|
||||
== GLOBAL VARIABLES ==
|
||||
command_bookmarklet_prefix:
|
||||
This variable determines the prefix of a command name.
|
||||
command_bookmarklet_use_sandbox:
|
||||
When this variable is 1, execute the script of bookmarklets in Sandbox.
|
||||
If you use NoScript addon, probably you should enable this option.
|
||||
|
||||
== KNOWN ISSUES ==
|
||||
When title has non-ASCII characters, it converts to unaccountable command.
|
||||
You should rewrite title of bookmarklet to ASCII characters, to escape this issue.
|
||||
|
||||
]]></detail>
|
||||
<detail lang="ja"><![CDATA[
|
||||
== SYNOPSIS ==
|
||||
このプラグインはブックマークレットを Vimperator で実行可能なコマンドに自動的に変換します。
|
||||
|
||||
== COMMAND ==
|
||||
固有のコマンドはありませんが、それぞれのブックマークレットは "bml" ではじまるコマンドに変換されます。
|
||||
|
||||
== EXAMPLE ==
|
||||
"Hatena-Bookmark" -> bmlhatena-bookmark
|
||||
|
||||
== GLOBAL VARIABLES ==
|
||||
command_bookmarklet_prefix:
|
||||
コマンドの先頭に付加される文字列を規定します。
|
||||
デフォルトは "bml"
|
||||
command_bookmarklet_use_sandbox:
|
||||
1 の時、ブックマークレットのスクリプトを sandbox で実行します。
|
||||
NoScript アドオンをつかっている場合は、このオプションを有効にする必要があるでしょう。
|
||||
|
||||
== KNOWN ISSUES ==
|
||||
タイトルに ASCII 文字以外が含まれている場合、わけのわからないコマンドになります。
|
||||
この問題を避けるためにブックマークレットのタイトルを ASCII 文字のみに書き換えることをおすすめします。
|
||||
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
|
||||
( function () {
|
||||
|
||||
let prefix = liberator.globalVariables.command_bookmarklet_prefix;
|
||||
if (prefix === undefined)
|
||||
prefix = 'bml';
|
||||
|
||||
let items = bookmarks.get('javascript:');
|
||||
if (!items.length) {
|
||||
liberator.echoerr('No bookmarks set');
|
||||
return;
|
||||
}
|
||||
|
||||
items.forEach(function (item) {
|
||||
let name = toValidCommandName(item.title);
|
||||
if (commands.get(name))
|
||||
return;
|
||||
commands.addUserCommand(
|
||||
[name],
|
||||
'bookmarklet : ' + item.title,
|
||||
function () evalScript(item.url),
|
||||
{ shortHelp: 'Bookmarklet' },
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
function toBoolean (value, def) {
|
||||
switch (typeof value) {
|
||||
case 'undefined':
|
||||
return def;
|
||||
case 'number':
|
||||
return !!value;
|
||||
case 'string':
|
||||
return !/^(\d+|false)$/i.test(value) || parseInt(value);
|
||||
default:
|
||||
return !!value;
|
||||
}
|
||||
}
|
||||
|
||||
function evalInSandbox (str) {
|
||||
let sandbox = new Components.utils.Sandbox("about:blank");
|
||||
sandbox.__proto__ = content.window.wrappedJSObject;
|
||||
return Components.utils.evalInSandbox(str, sandbox);
|
||||
}
|
||||
|
||||
function evalScript (url) {
|
||||
if (toBoolean(liberator.globalVariables.command_bookmarklet_use_sandbox, false)) {
|
||||
evalInSandbox(decodeURIComponent(url.replace(/^\s*javascript:/i, '')));
|
||||
} else {
|
||||
liberator.open(url);
|
||||
}
|
||||
}
|
||||
|
||||
function toValidCommandName(str) {
|
||||
str = prefix + escape(str.replace(/ +/g, '').toLowerCase()).replace(/[^a-zA-Z]+/g,'');
|
||||
return str.substr(0, str.length > 50 ? 50 : str.length);
|
||||
}
|
||||
|
||||
} )();
|
||||
// vim:sw=2 ts=2 et:
|
|
@ -1,183 +0,0 @@
|
|||
liberator.plugins.cssRules = function () {
|
||||
|
||||
liberator.commands.addUserCommand(
|
||||
["css[rule]"],
|
||||
"Sets CSS rule for current page",
|
||||
function (args, count, special) {
|
||||
// 1 2 3 4
|
||||
var matches = args.match(/^\s*?([:\[\]"'^*~|= #.,a-zA-Z0-9_>+-]+)(\s*([-+^])?=\s*(.*))?\s*$/);
|
||||
var ruleName = matches[1];
|
||||
var setValue = !!matches[2];
|
||||
var operator = matches[3];
|
||||
var ruleValue = matches[4];
|
||||
if (count > 0) count = count - 1; else count = -1;
|
||||
|
||||
var rule = liberator.plugins.cssRules.getRule(ruleName, count);
|
||||
if (!rule) {
|
||||
if (special) {
|
||||
rule = liberator.plugins.cssRules.addRule(ruleName, count);
|
||||
if (!rule) {
|
||||
liberator.echoerr("Failed to add CSS rule '" + ruleName + "'!");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
liberator.echoerr("CSS rule '" + ruleName + "' was not found!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!setValue) {
|
||||
liberator.echo(rule.selectorText + " {\n\t" + rule.style.cssText.replace(/; /g, ";\n\t") + "\n}");
|
||||
} else {
|
||||
liberator.plugins.cssRules.setRule(rule, ruleValue)
|
||||
}
|
||||
}, {}, true
|
||||
);
|
||||
|
||||
liberator.commands.addUserCommand(
|
||||
["rmcss[rule]"],
|
||||
"Remove CSS rule for current page",
|
||||
function (args, count, special) {
|
||||
var args = args.replace(/^\s*/, "").replace(/\s*$/, "");
|
||||
if (args.match(/[^:\[\]"'^*~|= #.,a-zA-Z0-9_>+-]/)) {
|
||||
liberator.echoerr("Not a CSS rule name: '" + args + "'!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count > 0) count = count - 1; else count = -1;
|
||||
var rule = liberator.plugins.cssRules.getRule(args, count);
|
||||
|
||||
if (!rule) {
|
||||
liberator.echoerr("CSS rule '" + args + "' was not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
liberator.plugins.cssRules.rmRule(rule);
|
||||
}, {}, true
|
||||
);
|
||||
|
||||
liberator.commands.addUserCommand(
|
||||
["cssrules"],
|
||||
"Lists all CSS rules for current page",
|
||||
function (args, count) {
|
||||
|
||||
var ss = liberator.tabs.getTab().linkedBrowser.contentDocument.styleSheets;
|
||||
var list = ":" + (liberator.util.escapeHTML(liberator.commandline.getCommand()) || ":cssrules") + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th colspan=\"2\">--- CSS rules ---</th></tr>";
|
||||
|
||||
var from = 0;
|
||||
var len = ss.length;
|
||||
|
||||
if (count > 0) {
|
||||
from = count - 1;
|
||||
len = count;
|
||||
}
|
||||
|
||||
for (var i = from; i < len; i++) {
|
||||
var href = ss[i].href;
|
||||
if (href)
|
||||
href = "<a href=\"#\" class=\"hl-URL\">" + liberator.util.escapeHTML(href) + "</a>";
|
||||
else
|
||||
href = "<span class=\"hl-InfoMsg\">Embedded Styles</span>";
|
||||
|
||||
var rules = "";
|
||||
for (var j = 0, lenj = ss[i].cssRules.length; j < lenj; j++) {
|
||||
rules += "<span style=\"font-weight: bold\">" + ss[i].cssRules[j].selectorText + "</span> {";
|
||||
rules += "<div style=\"margin-left: 2em\">" + ss[i].cssRules[j].style.cssText.replace(/; /g, ";<br/>") + "</div>}<br/><br/>";
|
||||
}
|
||||
list += "<tr align=\"left\"><th>" + (i + 1) + ":</th>" + href + "</th></tr>";
|
||||
list += "<tr><td> </td><td>" + rules + "</td></tr>";
|
||||
}
|
||||
list += "</table>";
|
||||
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
|
||||
}, {}, true
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
getRule: function (filter, num) {
|
||||
filter = filter.toLowerCase();
|
||||
var ss = liberator.tabs.getTab().linkedBrowser.contentDocument.styleSheets;
|
||||
|
||||
if (num >= 0) {
|
||||
|
||||
if (num <= ss.length) {
|
||||
var rules = ss[num].cssRules;
|
||||
for (var i = 0, len = rules.length; i < len; i++) {
|
||||
if (rules[i].selectorText == filter) {
|
||||
return rules[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
for (var j = 0, lenj = ss.length; j < lenj; j++) {
|
||||
for (var i = 0, len = ss[j].cssRules.length; i < len; i++) {
|
||||
if (ss[j].cssRules[i].selectorText == filter) {
|
||||
return ss[j].cssRules[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
setRule: function (rule, ruleValue) {
|
||||
var rulesList = ruleValue.split("; ");
|
||||
for (var i = 0; i < rulesList.length; i++) {
|
||||
var data = rulesList[i].match(/^\s*([a-zA-Z-]+)\s*:\s*(.*?)\s*;?$/);
|
||||
if (data) {
|
||||
var important = data[2].match(/!\s*important$/);
|
||||
if (important) data[2] = data[2].substring(0, data[2].length - important.length);
|
||||
rule.style.setProperty(data[1], data[2], important? "important": "");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addRule: function (name, num, place) {
|
||||
var ss = liberator.tabs.getTab().linkedBrowser.contentDocument.styleSheets;
|
||||
var newPlace;
|
||||
|
||||
if (num >= ss.length) return null;
|
||||
if (num < 0) num = 0;
|
||||
|
||||
if (!place) place = ss[num].cssRules.length;
|
||||
|
||||
try {
|
||||
var newPlace = ss[num].insertRule(name + "{}", place);
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ss[num].cssRules[newPlace];
|
||||
},
|
||||
|
||||
rmRule: function (rule) {
|
||||
var ss = rule.parentStyleSheet;
|
||||
var num = -1;
|
||||
for (var i = 0; i < ss.cssRules.length; i++) {
|
||||
if (ss.cssRules[i] == rule) {
|
||||
num = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num < 0) return false;
|
||||
|
||||
try {
|
||||
ss.deleteRule(num);
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} ();
|
||||
|
|
@ -1,229 +0,0 @@
|
|||
/* {{{
|
||||
Copyright (c) 2008-2009, anekos.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. The names of the authors may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
###################################################################################
|
||||
# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license #
|
||||
# に参考になる日本語訳がありますが、有効なのは上記英文となります。 #
|
||||
###################################################################################
|
||||
|
||||
}}} */
|
||||
|
||||
// PLUGIN_INFO {{{
|
||||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>every.js</name>
|
||||
<description>to run a specified command every time at specified interval.</description>
|
||||
<description lang="ja">指定のコマンドを指定の間隔で実行する。</description>
|
||||
<version>1.3.1</version>
|
||||
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
|
||||
<license>new BSD License (Please read the source code comments of this plugin)</license>
|
||||
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/every.js</updateURL>
|
||||
<minVersion>2.3</minVersion>
|
||||
<maxVersion>2.3</maxVersion>
|
||||
<detail><![CDATA[
|
||||
== Usage ==
|
||||
:[INTERVAL]every [-i[nterval]=INTERVAL] [-init=INITIALIZE_COMMAND] [-from=COUNTER_FORM] [-step=COUNTER_STEP]<COMMAND>:
|
||||
run <COMMAND> every time at [INTERVAL] sec.
|
||||
|
||||
:[INTERVAL]delay [-i[nterval]=INTERVAL] <COMMAND>:
|
||||
run <COMMAND> after [INTERVAL] sec.
|
||||
|
||||
:every! <PROCESS-ID>:
|
||||
kill specified process.
|
||||
|
||||
The default value of [INTERVAL] is 1 sec.
|
||||
While Vimperator's focus is at command-line,
|
||||
these commands does not run.
|
||||
|
||||
== Links ==
|
||||
http://d.hatena.ne.jp/nokturnalmortum/20081102#1225552718
|
||||
]]></detail>
|
||||
<detail lang="ja"><![CDATA[
|
||||
== Usage ==
|
||||
:[INTERVAL]every [-i[nterval]=INTERVAL] [-init=INITIALIZE_COMMAND] [-from=COUNTER_FROM] [-step=COUNTER_STEP]<COMMAND>:
|
||||
[INTERVAL] 間隔で <COMMAND> を走らせる。
|
||||
|
||||
:[INTERVAL]delay [-i[nterval]=INTERVAL] <COMMAND>:
|
||||
[INTERVAL] 秒後に <COMMAND> を走らせる。
|
||||
|
||||
:every! <PROCESS-ID>:
|
||||
指定のプロセスを殺す。
|
||||
|
||||
INTERVAL:
|
||||
INTERVAL のデフォルトは 1秒。
|
||||
オプションでの指定時には、"s[ec]", "m[in]", "h[our]" の単位で指定可能。(e.g. "0.5hour")
|
||||
コマンドラインにいるときには、実行されないようになっている。
|
||||
INITIALIZE_COMMAND:
|
||||
指定すると、:every 実行直後にそれが実行されます。
|
||||
COUNTER_FROM/COUNTER_STEP:
|
||||
何れか一方を指定すると、COMMAND 中の "<counter>" という文字が、カウンター数字に置換されます。
|
||||
この数字は、COUNTER_FROM で初期化され、every での実行毎に COUNTER_STEP ずつ増えます。
|
||||
|
||||
== Links ==
|
||||
http://d.hatena.ne.jp/nokturnalmortum/20081102#1225552718
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
// }}}
|
||||
|
||||
ps = [];
|
||||
|
||||
(function () {
|
||||
|
||||
let (every = liberator.plugins.every) {
|
||||
if (every && every.ps)
|
||||
kill('*');
|
||||
}
|
||||
|
||||
function defined (value)
|
||||
(typeof value !== 'undefined');
|
||||
|
||||
function defaultValue (value, def)
|
||||
(defined(value) ? value : def);
|
||||
|
||||
function run (command, interval, opts) {
|
||||
let process = {
|
||||
handle: null,
|
||||
command: command,
|
||||
options: opts
|
||||
};
|
||||
if (opts.init)
|
||||
liberator.execute(opts.init);
|
||||
let fun = function () {
|
||||
if (liberator.mode == liberator.modules.modes.COMMAND_LINE)
|
||||
return;
|
||||
let cmd = process.command;
|
||||
if (defined(opts.from) || defined(opts.step)) {
|
||||
if (!defined(process.counter))
|
||||
process.counter = defaultValue(opts.from, 1);
|
||||
cmd = cmd.replace(/<counter>/i, process.counter);
|
||||
process.counter += defaultValue(opts.step, 1);
|
||||
}
|
||||
liberator.execute(cmd);
|
||||
};
|
||||
process.handle = setInterval(fun, parseInt(interval, 10));
|
||||
ps.push(process);
|
||||
}
|
||||
|
||||
function kill (index) {
|
||||
if (index == '*') {
|
||||
ps.forEach(function (process) clearInterval(process.handle));
|
||||
liberator.echo(ps.length + ' processes were killed!');
|
||||
ps = [];
|
||||
} else {
|
||||
let process = ps[index];
|
||||
if (process) {
|
||||
clearInterval(process.handle);
|
||||
ps.splice(index, index);
|
||||
liberator.echo('process "' + process.command + '" was killed!');
|
||||
} else {
|
||||
liberator.echoerr('unknown process');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function msec (count) {
|
||||
return (count > 0) ? count * 1000 : 1000;
|
||||
}
|
||||
|
||||
function expandSuffix (s) {
|
||||
const tbl = {
|
||||
'^s(ec)?$': 1,
|
||||
'^m(in)?$': 60,
|
||||
'^h(our)?$': 60 * 60
|
||||
};
|
||||
let [, a, b] = s.match(/^([\d\.]+)(.*)$/);
|
||||
let v = parseFloat(a);
|
||||
for (let e in tbl)
|
||||
if (b.match(e))
|
||||
return v * tbl[e];
|
||||
return v;
|
||||
}
|
||||
|
||||
liberator.modules.commands.addUserCommand(
|
||||
['every', 'ev'],
|
||||
'every',
|
||||
function (args) {
|
||||
if (args.bang) {
|
||||
kill(args.literalArg);
|
||||
} else {
|
||||
let interval = args['-interval'];
|
||||
let opts = {};
|
||||
'from step init'.split(' ').forEach(function (v) (opts[v] = args['-' + v]));
|
||||
run(args.literalArg, msec(interval ? expandSuffix(interval) : args.count), opts);
|
||||
}
|
||||
},
|
||||
{
|
||||
literal: 0,
|
||||
count: true,
|
||||
bang: true,
|
||||
completer: function (context, args) {
|
||||
if (args.bang) {
|
||||
context.title = ['PID', 'every process'];
|
||||
context.completions = [['*', 'kill em all']].concat(ps.map(function (p, i) ([i.toString(), p.command])));
|
||||
} else {
|
||||
liberator.modules.completion.ex(context);
|
||||
}
|
||||
},
|
||||
options: [
|
||||
[['-interval', '-i'], commands.OPTION_ANY],
|
||||
[['-from', '-f'], commands.OPTION_FLOAT],
|
||||
[['-step', '-s'], commands.OPTION_FLOAT],
|
||||
[['-init', '-i'], commands.OPTION_STRING],
|
||||
]
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
liberator.modules.commands.addUserCommand(
|
||||
['delay'],
|
||||
'delay',
|
||||
function (args) {
|
||||
let cmd = args.literalArg;
|
||||
let f = function () {
|
||||
if (liberator.mode == liberator.modules.modes.COMMAND_LINE) {
|
||||
setTimeout(f, 500);
|
||||
} else {
|
||||
liberator.execute(cmd);
|
||||
}
|
||||
};
|
||||
let interval = args['-interval'];
|
||||
setTimeout(f, msec(interval ? expandSuffix(interval) : args.count));
|
||||
},
|
||||
{
|
||||
literal: 0,
|
||||
count: true,
|
||||
completer: function (context) liberator.modules.completion.ex(context),
|
||||
options: [
|
||||
[['-interval', '-i'], commands.OPTION_ANY]
|
||||
]
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
})();
|
|
@ -1,46 +0,0 @@
|
|||
// INFO //
|
||||
var INFO =
|
||||
<plugin name="gmap.js" version="0.1"
|
||||
summary="Get google maps URL of current machine location."
|
||||
href="http://github.com/vimpr/vimperator-plugins/blob/master/gmap.js"
|
||||
xmlns="http://vimperator.org/namespaces/liberator">
|
||||
<author email="mitsugu.oyama@gmail.com">Mitsugu Oyama</author>
|
||||
<license href="http://opensource.org/licenses/mit-license.php">MIT</license>
|
||||
<project name="Vimperator" minVersion="2.3"/>
|
||||
<p>
|
||||
You can get Google Maps URL of current machine location by this plugin.
|
||||
</p>
|
||||
<item>
|
||||
<tags>'GoogleMaps'</tags>
|
||||
<spec>:gmap</spec>
|
||||
<description>
|
||||
<p>You can get Google Maps URL of current machine location by this plugin.</p>
|
||||
<dl>
|
||||
<dt>See.</dt>
|
||||
<dd>
|
||||
<p><link topic="http://mozilla.jp/firefox/features/geolocation/">http://mozilla.jp/firefox/features/geolocation/</link> (Japanese)</p>
|
||||
<p><link topic="https://developer.mozilla.org/Ja/Using_geolocation">https://developer.mozilla.org/Ja/Using_geolocation</link> (Japanese)</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</description>
|
||||
</item>
|
||||
</plugin>;
|
||||
|
||||
(function(){
|
||||
commands.addUserCommand(
|
||||
['gmap'],
|
||||
'Get Google Map URL of current location',
|
||||
function(){
|
||||
let strURL='http://maps.google.com/maps?ie=UTF8&q=';
|
||||
let Cc=Components.classes;
|
||||
let Ci=Components.interfaces;
|
||||
let geolocation=Cc["@mozilla.org/geolocation;1"]
|
||||
.getService(Ci.nsIDOMGeoGeolocation);
|
||||
geolocation.getCurrentPosition(function(position){
|
||||
let strL=position.coords.latitude+','+position.coords.longitude;
|
||||
liberator.echo(strURL+strL);
|
||||
util.copyToClipboard(strURL+strL,true);
|
||||
});
|
||||
}
|
||||
);
|
||||
})();
|
|
@ -1,89 +0,0 @@
|
|||
// PLUGIN_INFO//{{{
|
||||
var PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>{NAME}</name>
|
||||
<description>hash of file</description>
|
||||
<author mail="konbu.komuro@gmail.com" homepage="http://d.hatena.ne.jp/hogelog/">hogelog</author>
|
||||
<version>0.2.2</version>
|
||||
<minVersion>2.3</minVersion>
|
||||
<maxVersion>2.3</maxVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/hash.js</updateURL>
|
||||
<detail><![CDATA[
|
||||
|
||||
== COMMANDS ==
|
||||
hash:
|
||||
:hash md2|md5|sha1|sha256|sha384|sha512 file-path
|
||||
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
//}}}
|
||||
|
||||
(function() {
|
||||
const PR_UINT_MAX = 0xffffffff;
|
||||
let Crypt = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash);
|
||||
let Algos = [
|
||||
["md2", "MD2 Algorithm"],
|
||||
["md5", "MD5 Algorithm"],
|
||||
["sha1", "SHA1 Algorithm"], // SHA-1
|
||||
["sha256", "SHA256 Algorithm"], // SHA-256
|
||||
["sha384", "SHA384 Algorithm"], // SHA-384
|
||||
["sha512", "SHA512 Algorithm"], // SHA-512
|
||||
];
|
||||
|
||||
function getStream(path)
|
||||
{
|
||||
let file = io.File(path);
|
||||
let stream = Cc["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Ci.nsIFileInputStream);
|
||||
stream.init(file, 0x01, 0444, 0);
|
||||
return stream;
|
||||
}
|
||||
|
||||
// return the two-digit hexadecimal code for a byte
|
||||
function toHexString(charCode)
|
||||
{
|
||||
return ("0" + charCode.toString(16)).slice(-2);
|
||||
}
|
||||
|
||||
|
||||
commands.addUserCommand(["hash"], "hash of file",
|
||||
function(args){
|
||||
if (args.length!=2) {
|
||||
|
||||
liberator.echo("usage \":hash md2|md5|sha1|sha256|sha384|sha512 file-path\"");
|
||||
return false;
|
||||
}
|
||||
let [algo, path] = args;
|
||||
let stream = getStream(path);
|
||||
|
||||
Crypt.initWithString(algo);
|
||||
|
||||
// read the entire stream
|
||||
Crypt.updateFromStream(stream, PR_UINT_MAX);
|
||||
|
||||
stream.close();
|
||||
|
||||
// get base-64 string
|
||||
let hash = Crypt.finish(false);
|
||||
|
||||
// convert the binary hash data to a hex string.
|
||||
let str = [toHexString(hash.charCodeAt(i)) for(i in hash)].join("");
|
||||
util.copyToClipboard(str, true);
|
||||
},
|
||||
{
|
||||
bang: true,
|
||||
completer: function (context, args){
|
||||
if (args.completeArg == 0) {
|
||||
context.title = ["hash", "algorithm"];
|
||||
context.completions = Algos;
|
||||
} else if (args.completeArg == 1) {
|
||||
completion.url(context, "f");
|
||||
}
|
||||
},
|
||||
literal: 1,
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
})();
|
||||
// vim: fdm=marker sw=4 ts=4 et:
|
|
@ -1,91 +0,0 @@
|
|||
var PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>{NAME}</name>
|
||||
<description>History search backward like UNIX shell.</description>
|
||||
<description lang="ja">UNIX シェルのような、C-rで履歴検索を行うプラグイン</description>
|
||||
<minVersion>2.0</minVersion>
|
||||
<maxVersion>2.0</maxVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/history-search-backward.js</updateURL>
|
||||
<author mail="hotchpotch@gmail.com" homepage="http://d.hatena.ne.jp/secondlife/">Yuichi Tateno</author>
|
||||
<license>MIT</license>
|
||||
<version>0.2</version>
|
||||
<detail><![CDATA[
|
||||
UNIX シェルのように、コマンドラインで C-r でヒストリ検索を行うプラグインです。map の変更設定は以下のように行えます。
|
||||
>||
|
||||
liberator.globalVariables.history_search_backward_map = ['<C-r>'];
|
||||
||<
|
||||
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
|
||||
(function() {
|
||||
let p = function(msg) {
|
||||
Application.console.log(''+msg);
|
||||
}
|
||||
|
||||
let evalWithContext = function(func, context) {
|
||||
let str;
|
||||
let fstr = func.toString();
|
||||
if (fstr.indexOf('function () {') == 0) {
|
||||
str = fstr.replace(/.*?{([\s\S]+)}.*?/m, "$1");
|
||||
} else {
|
||||
str = '(' + fstr + ')()';
|
||||
}
|
||||
return liberator.eval(str, context);
|
||||
}
|
||||
|
||||
let showCompletions = function() {
|
||||
if (!options.get('wildoptions').has('auto')) {
|
||||
evalWithContext(function() {
|
||||
completions.complete(true, false);
|
||||
completions.itemList.show();
|
||||
}, commandline.input);
|
||||
}
|
||||
}
|
||||
|
||||
let next = function() {
|
||||
evalWithContext(function() completions.tab(false), commandline.input);
|
||||
}
|
||||
|
||||
let prev = function() {
|
||||
evalWithContext(function() completions.tab(true), commandline.input);
|
||||
}
|
||||
|
||||
const commandlineWidget = document.getElementById("liberator-commandline");
|
||||
|
||||
mappings.addUserMap([modes.COMMAND_LINE],
|
||||
liberator.globalVariables.history_search_backward_map || ['<C-r>'],
|
||||
'History incremental search backward.',
|
||||
function()
|
||||
{
|
||||
if (evalWithContext(function() completions.itemList.visible(), commandline.input)) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
let command = commandline.command || '';
|
||||
let completionsList = [[key, i] for ([i, key] in storage['history-command'])].
|
||||
filter(function([key, i]) key).reverse();
|
||||
|
||||
commandline.input('bck-i-search: ', function(str) {
|
||||
try {
|
||||
liberator.execute(str);
|
||||
} catch(e) {};
|
||||
modes.pop();
|
||||
return;
|
||||
}, {
|
||||
completer: function(context) {
|
||||
context.title = ['CommandLine History', 'INDEX'];
|
||||
context.completions = completionsList;
|
||||
},
|
||||
onChange: function() {
|
||||
showCompletions();
|
||||
},
|
||||
default: command,
|
||||
});
|
||||
showCompletions();
|
||||
}
|
||||
);
|
||||
})();
|
||||
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
let INFO = //{{{
|
||||
<plugin name="statusbar panel" version="0.1"
|
||||
href="https://github.com/vimpr/vimperator-plugins/raw/master/statusbar_panel.js"
|
||||
summary="Click statusbar panel"
|
||||
lang="ja"
|
||||
xmlns="http://vimperator.org/namespaces/liberator">
|
||||
<author href="http://d.hatena.ne.jp/wlt/" email="wltlain@gmail.com">wlt</author>
|
||||
<license href="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
|
||||
<project name="vimperator" minVersion="2.3.1"/>
|
||||
<p>
|
||||
ステータスバー(アドオンバー)にあるパネル(アイコン)をクリックするコマンドを提供します。
|
||||
</p>
|
||||
<item>
|
||||
<tags>:statusbarpanel</tags>
|
||||
<spec>:statusbarpanel <oa>-button=<a>l | m | r</a></oa> <oa>-double-click</oa> <a>panel-id</a></spec>
|
||||
<description>
|
||||
<p>
|
||||
<a>panel-id</a>で指定するID属性を持つステータスバーパネル(アイコン)をクリックします。
|
||||
クリックするボタンは<oa>-button=</oa>で指定できます:
|
||||
</p>
|
||||
<dl>
|
||||
<dt>l</dt>
|
||||
<dd>左ボタン(デフォルト)</dd>
|
||||
<dt>m</dt>
|
||||
<dd>中ボタン(スクロールボタン)</dd>
|
||||
<dt>r</dt>
|
||||
<dd>右ボタン</dd>
|
||||
</dl>
|
||||
<p><oa>-double-click</oa>を指定するとダブルクリックになります。</p>
|
||||
</description>
|
||||
</item>
|
||||
</plugin>;
|
||||
//}}}
|
||||
|
||||
let MOUSE_BUTTON_LEFT = 0;
|
||||
let MOUSE_BUTTON_MIDDLE = 1;
|
||||
let MOUSE_BUTTON_RIGHT = 2;
|
||||
|
||||
function getImages(panel) {
|
||||
var images = [];
|
||||
// 普通の子孫要素のimage要素探索
|
||||
for (let [k, node] in Iterator(panel.getElementsByTagName('image'))) images.push(node);
|
||||
// 匿名コンテントの子孫要素のimage要素探索
|
||||
var anonymousNodes = document.getAnonymousNodes(panel);
|
||||
for (let [k, anonymousNode] in Iterator(anonymousNodes)) {
|
||||
let node;
|
||||
let result = document.evaluate('descendant-or-self::xul:image', anonymousNode, function() XUL.uri, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
|
||||
while ((node = result.iterateNext())) images.push(node);
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
function makeIcon(panel) {
|
||||
var icon = <image xmlns={XUL.uri}/>;
|
||||
var image = getImages(panel)[0];
|
||||
|
||||
if (image) {
|
||||
let style = window.getComputedStyle(image, null);
|
||||
let src = image.src || style.listStyleImage.replace(/^url\("(.+)"\)$/, '$1');
|
||||
if (src != '') {
|
||||
icon.@style = 'list-style-image: url("' + src + '");' +
|
||||
'-moz-image-region: ' + style.MozImageRegion;
|
||||
}
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
function generateStatusbarpaneIDlList(filter) {
|
||||
var panels = document.getElementsByTagNameNS(XUL.uri, 'statusbarpanel');
|
||||
for ([k, p] in Iterator(panels)) {
|
||||
if (p.hidden != true) {
|
||||
yield {
|
||||
text: p.id,
|
||||
desc: 'statusbarpanel',
|
||||
icon: makeIcon(p)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createAndDispatchEvent(target, type, detail, screenX, screenY, button) {
|
||||
var ev = document.createEvent('MouseEvents');
|
||||
ev.initMouseEvent(type, true, true, window, detail, screenX, screenY, 0, 0, false, false, false, false, button, null);
|
||||
target.dispatchEvent(ev);
|
||||
}
|
||||
|
||||
function clickStatusIcon(panel, button, doubleClick) {
|
||||
var target = getImages(panel)[0] || panel;
|
||||
if (!target) return;
|
||||
var x = target.boxObject.screenX;
|
||||
var y = target.boxObject.screenY;
|
||||
x += target.clientWidth / 2;
|
||||
y += target.clientHeight / 2;
|
||||
|
||||
// イベントの発生順序 http://www.quirksmode.org/dom/events/click.html
|
||||
createAndDispatchEvent(target, 'mousedown', 0, x, y, button);
|
||||
createAndDispatchEvent(target, 'mouseup', 0, x, y, button);
|
||||
createAndDispatchEvent(target, 'click', 1, x, y, button);
|
||||
|
||||
if (doubleClick) {
|
||||
createAndDispatchEvent(target, 'mousedown', 0, x, y, button);
|
||||
createAndDispatchEvent(target, 'mouseup', 0, x, y, button);
|
||||
createAndDispatchEvent(target, 'click', 1, x, y, button);
|
||||
createAndDispatchEvent(target, 'dblclick', 2, x, y, button);
|
||||
} else if (button == MOUSE_BUTTON_RIGHT) {
|
||||
createAndDispatchEvent(target, 'contextmenu', 1, x, y, button);
|
||||
}
|
||||
}
|
||||
|
||||
commands.addUserCommand(['statusbarpanel'],'click statusbar panel',
|
||||
function(args) {
|
||||
var id = args[0];
|
||||
var panel = document.getElementById(id);
|
||||
if (!panel) {
|
||||
liberator.echoerr('No such statusbar panel: ' + id);
|
||||
return;
|
||||
}
|
||||
var button = MOUSE_BUTTON_LEFT;
|
||||
switch (args['-button']) {
|
||||
case 'm': button = MOUSE_BUTTON_MIDDLE; break;
|
||||
case 'r': button = MOUSE_BUTTON_RIGHT; break;
|
||||
case 'l': default: button = MOUSE_BUTTON_LEFT; break;
|
||||
}
|
||||
clickStatusIcon(panel, button, args['-double-click']);
|
||||
}, {
|
||||
argCount: '1',
|
||||
options: [
|
||||
[['-button', '-b'], commands.OPTION_STRING,
|
||||
function(arg) /^[lmr]$/.test(arg),
|
||||
[['l', 'Left click (default)'],
|
||||
['m', 'Middle click'],
|
||||
['r', 'Right click']]],
|
||||
[['-double-click', '-d'], commands.OPTION_NOARG]
|
||||
],
|
||||
completer: function(context, args) {
|
||||
var arg = args[0];
|
||||
context.anchored = false;
|
||||
context.title = ['Panel ID'];
|
||||
context.keys = { text: 'text', description: 'desc', icon: 'icon' };
|
||||
context.compare = CompletionContext.Sort.unsorted;
|
||||
context.process = [function (item, text) {
|
||||
return <><span highlight="CompIcon">{item.icon ? item.icon : <></>}</span><span class="td-strut"/>{text}</>
|
||||
}];
|
||||
|
||||
var list = generateStatusbarpaneIDlList(arg);
|
||||
context.completions = list;
|
||||
}
|
||||
}, true);
|
||||
|
||||
// vim: set sw=4 ts=4 et fdm=marker :
|
File diff suppressed because it is too large
Load diff
|
@ -1,98 +0,0 @@
|
|||
var PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>{NAME}</name>
|
||||
<description>Send to your Android Phone</description>
|
||||
<description lang="ja">Android 端末に URL などを送信します</description>
|
||||
<author mail="hotchpotch@gmail.com">Yuichi Tateno</author>
|
||||
<minVersion>2.3</minVersion>
|
||||
<maxVersion>2.3</maxVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/vimp_to_android_phone.js</updateURL>
|
||||
</VimperatorPlugin>;
|
||||
|
||||
(function() {
|
||||
|
||||
var apiVersion = '3';
|
||||
var base = 'http://chrometophone.appspot.com';
|
||||
var baseURL = base + '/send?ver=' + apiVersion;
|
||||
var signInURL = base + '/signin?extret=about:blankZ&ver=' + apiVersion;
|
||||
var signOutURL = base + '/signout?extret=about:blankZ&ver=' + apiVersion;
|
||||
// var loginURL = 'https://www.google.com/accounts/ServiceLoginAuth?service=ah&sig=d71ef8b8d6150b23958ad03b3bf546b7';
|
||||
|
||||
var serialize = function(hash) {
|
||||
var res = [];
|
||||
for (var key in hash) {
|
||||
res.push(encodeURIComponent(key) + '=' + encodeURIComponent(hash[key]));
|
||||
}
|
||||
return res.join('&');
|
||||
}
|
||||
|
||||
var sendToPhone = function(requestURL) {
|
||||
requestURL = baseURL + '&' + requestURL;
|
||||
var req = new libly.Request(requestURL, {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'X-Extension': 'true'
|
||||
});
|
||||
req.addEventListener('success', function(res) {
|
||||
var body = res.responseText;
|
||||
if (body.substring(0, 2) == 'OK') {
|
||||
liberator.echo('Send to phone successed.');
|
||||
} else if (body.indexOf('LOGIN_REQUIRED' == 0)) {
|
||||
liberator.echo('Please login first');
|
||||
liberator.open(signInURL, liberator.NEW_TAB);
|
||||
} else if (body.indexOf('DEVICE_NOT_REGISTERED') == 0) {
|
||||
liberator.echo('device not registered');
|
||||
liberator.open(signOutURL, liberator.NEW_TAB);
|
||||
}
|
||||
});
|
||||
req.addEventListener('failure', function(res) {
|
||||
liberator.echoerr('Send to phone failed.');
|
||||
});
|
||||
req.get();
|
||||
}
|
||||
|
||||
liberator.modules.commands.addUserCommand(["sp[hone]"], "Sent to your Android Phone",
|
||||
function(args) {
|
||||
if (args && args['-login']) {
|
||||
liberator.open(signInURL, liberator.NEW_TAB);
|
||||
return;
|
||||
} else if (args && args['-logout']) {
|
||||
liberator.open(signOutURL, liberator.NEW_TAB);
|
||||
return;
|
||||
}
|
||||
|
||||
var req = {
|
||||
sel: libly.$U.getSelectedString()
|
||||
};
|
||||
|
||||
if (args && !args.arguments && !args['-title'])
|
||||
req.url = args[0];
|
||||
else if (args && args.arguments)
|
||||
req.url = args.arguments[0];
|
||||
|
||||
if (args && args['-title'])
|
||||
req.title = args['-title'];
|
||||
else if (!req.url)
|
||||
req.title = content.document.title;
|
||||
|
||||
if (!req.url) req.url = content.location.href;
|
||||
if (!req.title) req.title = req.url;
|
||||
|
||||
if (!req.url || !req.url.match(/^https?/)) {
|
||||
liberator.echoerr('http/https schema only');
|
||||
return;
|
||||
};
|
||||
sendToPhone(serialize(req));
|
||||
}, {
|
||||
options: [
|
||||
[["-title", "-t"], liberator.modules.commands.OPTION_STRING],
|
||||
[["-login"], liberator.modules.commands.OPTION_NOARG],
|
||||
[["-logout"], liberator.modules.commands.OPTION_NOARG],
|
||||
]
|
||||
}, {
|
||||
// replace: true
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
set gui=none
|
||||
set toolbars=none
|
||||
set hintchars=hjklasdfgyuiopqwertnmzxcvb
|
||||
set visualbell=true
|
||||
set complete=lStf
|
||||
|
|
91
sxhkd/sxhkdrc
Normal file
91
sxhkd/sxhkdrc
Normal file
|
@ -0,0 +1,91 @@
|
|||
#
|
||||
# bspwm hotkeys
|
||||
#
|
||||
|
||||
super + shift + q
|
||||
bspc quit
|
||||
|
||||
super + q
|
||||
bspc window -c
|
||||
|
||||
super + t
|
||||
bspc desktop -l next
|
||||
|
||||
super + b
|
||||
bspc desktop -B
|
||||
|
||||
super + {s,f}
|
||||
bspc window -t {floating,fullscreen}
|
||||
|
||||
super + {grave,Tab}
|
||||
bspc {window,desktop} -f last
|
||||
|
||||
super + apostrophe
|
||||
bspc window -s last
|
||||
|
||||
super + {o,i}
|
||||
bspc control --record-history off; \
|
||||
bspc window {older,newer} -f; \
|
||||
bspc control --record-history on
|
||||
|
||||
super + y
|
||||
bspc window -w last.manual
|
||||
|
||||
super + m
|
||||
bspc window -s biggest
|
||||
|
||||
super + {_,shift + }{h,j,k,l}
|
||||
bspc window -{f,s} {left,down,up,right}
|
||||
|
||||
super + {_,shift + }c
|
||||
bspc window -f {next,prev}
|
||||
|
||||
super + {comma,period}
|
||||
bspc desktop -C {backward,forward}
|
||||
|
||||
super + bracket{left,right}
|
||||
bspc desktop -f {prev,next}
|
||||
|
||||
super + ctrl + {h,j,k,l}
|
||||
bspc window -p {left,down,up,right}
|
||||
|
||||
super + ctrl + {_,shift + }space
|
||||
bspc {window -p cancel,desktop -c}
|
||||
|
||||
super + alt + {h,j,k,l}
|
||||
bspc window -e {left -10,down +10,up -10,right +10}
|
||||
|
||||
super + alt + shift + {h,j,k,l}
|
||||
bspc window -e {right -10,up +10,down -10,left +10}
|
||||
|
||||
super + ctrl + {1-9}
|
||||
bspc window -r 0.{1-9}
|
||||
|
||||
super + {_,shift + }{1-9,0}
|
||||
bspc {desktop -f,window -d} ^{1-9,10}
|
||||
|
||||
~button1
|
||||
bspc pointer -g focus
|
||||
|
||||
super + button{1-3}
|
||||
bspc pointer -g {move,resize_side,resize_corner}
|
||||
|
||||
super + !button{1-3}
|
||||
bspc pointer -t %i %i
|
||||
|
||||
super + @button{1-3}
|
||||
bspc pointer -u
|
||||
|
||||
#
|
||||
# wm independent hotkeys
|
||||
#
|
||||
|
||||
super + Return
|
||||
urxvt
|
||||
|
||||
super + p
|
||||
rofi -show run
|
||||
|
||||
# make sxhkd reload its configuration files:
|
||||
super + Escape
|
||||
pkill -USR1 -x sxhkd
|
Loading…
Reference in a new issue