aboutsummaryrefslogtreecommitdiffstats
path: root/prevent_focus_ietab.js
blob: d0d8adc9f37fb40200a044a84588d3a7b440136a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// prevent_focus_ietab.js
//
// LICENSE: {{{
// Copyright (c) 2009 snaka<snaka.gml@gmail.com>
//
// Distributable under the terms of an new BSD style license.
// }}}
//
// PLUGIN INFO: {{{
var PLUGIN_INFO =
<VimperatorPlugin>
  <name>prevent_focus_ietab</name>
  <description>This plugin prevents focusing IETab automaticaly.</description>
  <description lang="ja">IETabに勝手にフォーカスを奪われてそうさ不能になるのを防ぐ</description>
  <minVersion>2.0pre</minVersion>
  <maxVersion>2.0</maxVersion>
  <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/prevent_focus_ietab.js</updateURL>
  <author mail="snaka.gml@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/snaka72/">snaka</author>
  <license>MIT style license</license>
  <version>1.0.1</version>
  <detail><![CDATA[
    == Subject ==
    This plugin prevents IEtab get focusing with mannerless.
    == Usage ==
    Place this file to vimp's plugin directory. That's all.
  ]]></detail>
  <detail lang="ja"><![CDATA[
    == 概要 ==
    IETabにフォーカスを勝手に奪われて操作不能になるのを防ぐ
    == 使い方 ==
    vimpのpluginディレクトリにこのファイルを格納してくださいそれだけです
  ]]></detail>
</VimperatorPlugin>;
// }}}

(function() {
  if (!gIeTab || !gIeTab.onTabSelected)
    return;

  liberator.log("replace IeTab.onTabSelected() function");
  var func = gIeTab.onTabSelected.toSource();
  var newFunc = func.replace(/window\.setTimeout\(gIeTab\.focusIeTab, 0\);/, '');
  gIeTab.removeEventListener("appcontent", "select", gIeTab.onTabSelected);
  gIeTab.addEventListener("appcontent", "select", new Function(newFunc));
})();

// vim:sw=2 ts=2 et si fdm=marker:
スタイルシートの適用を可能にします * @author teramako teramako@gmail.com * @url http://coderepos.org/share/wiki/VimperatorPlugin/stylechanger.js * @license MPL 1.1/GPL 2.0/LGPL 2.1 * @version 0.3c * ==/VimperatorPlugin== * * Usage: * * :hi[ghlight] [groupName] -> list all or specified group temporary-style(s) * :hi[ghlight] clear [groupName} -> clear all or specified group temporary-styles * :hi[ghlight] {groupName} {style...} -> define style as {groupName} * * :altcolo[rschema] -> list available site alternative styles (`*'-marked is current style) * :altcolo[rschema] {altStyleName} -> switch to the style * * :colo[rschema] -> list available user stylesheets (`*'-marked are loaded styles) * :colo[rschema] {styleName} -> enable the style * :colo[rschema]! {styleName} -> disable the style * * {styleName} -> the name taked away from a CSS-file-name '.css' suffix * CSS-file are put in "~/vimperator/colors" directory * * `colors[chema]' command is similar to Stylish * * Example: * * auto load settings * let g:styles = "style, name" * */ (function(){ liberator.plugins.styleSheetsManger = (function(){ var sss = Components.classes['@mozilla.org/content/style-sheet-service;1'].getService(Components.interfaces.nsIStyleSheetService); var ios = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService); var CSSDataPrefix = 'data:text/css,'; function init() { if (globalVariables.styles) globalVariables.styles.split(/\s*,\s*/).forEach(manager.load); } function getCSSFiles() { var files = []; io.getRuntimeDirectories('colors') .filter(function(colorDir) colorDir) .forEach(function(colorDir) io.readDirectory(colorDir) .forEach(function(file) { if (/\.css$/.test(file.leafName.toLowerCase()) && !file.isDirectory()) { files.push(file); } })); return files; } function getURIFromName(aName){ var ret = null; io.getRuntimeDirectories('colors').some(function(file){ file.append(aName + '.css'); if (file.exists()){ ret = ios.newFileURI(file); return true; } }); return ret; } function getURIFromCSS(aString) ios.newURI('data:text/css,' + aString, null, null); function getStylesheetList(){ var list = []; var stylesheets = getAllStyleSheets(window.content); stylesheets.forEach(function(style){ var media = style.media.mediaText.toLowerCase(); if (media && media.indexOf('screen') == -1 && media.indexOf('all') == -1) return; if (style.title) list.push([style.title, style.disabled === true ? false : true]); }); return list; } var manager = { load: function(css){ if (!css) return false; var uri = null; if (typeof css == 'string'){ uri = getURIFromName(css); } else if (css instanceof Components.interfaces.nsIURI){ uri = css; } if (!uri) return false; if (sss.sheetRegistered(uri, sss.USER_SHEET)) sss.unregisterSheet(uri, sss.USER_SHEET); sss.loadAndRegisterSheet(uri, sss.USER_SHEET); if (options.verbose > 8) log('Resisted colorschema '+css); return true; }, unload: function(css){ if (!css) return false; var uri = null; if (typeof css == 'string'){ uri = getURIFromName(css); } else if (css instanceof Components.interfaces.nsIURI){ uri = css; } if (!uri) return false; if (sss.sheetRegistered(uri, sss.USER_SHEET)) sss.unregisterSheet(uri, sss.USER_SHEET); if (options.verbose > 8) log('Unresisted colorschema '+css); return true; }, list: function(isAltanative){ var str = []; if (isAltanative){ str.push('<span class="hl-Title">Alternative StyleSheet List</span>'); getStylesheetList().forEach(function(elm, i){ var buf = ' ' + (i+1) + ' '; if (elm[1]){ buf += '<span style="color:blue">*</span>'; } else { buf += ' '; } str.push(buf + ' ' + elm[0]); });; if (str.length == 1) str = ['Alternative StyleSheet is none.']; } else { str.push('<span class="hl-Title">User StyleSheet List</span>'); var files = getCSSFiles().map(function(file) file.leafName.replace(/\.css$/i, '')); files.forEach(function(file, i){ var buf = ' ' + (i+1) + ' '; if (sss.sheetRegistered(getURIFromName(file), sss.USER_SHEET)){ buf += '<span style="color:blue">*</span>'; } else { buf += ' '; } str.push(buf +' ' + file); }); } echo(str.join('\n'), true); }, get highlightList(){ return CSSData; } }; commands.addUserCommand(['altcolo[rschema]'], 'set alternativeStyleSheet', function(arg){ if (!arg){ manager.list(true); return; } else if (getStylesheetList().some(function(elm) elm[0] == arg)){ stylesheetSwitchAll(window.content, arg); setStyleDisabled(false); } }, { completer: function(aFilter){ var styles = getStylesheetList().map(function(elm) [elm[0], elm[1] ? '* ' : ' ' + 'alternative style']); if (!aFilter) return [0, styles]; var candidates = styles.filter(function(elm) elm[0].indexOf(aFilter) == 0); return [0, candidates]; } } ); commands.addUserCommand(['colo[rschema]'], 'set user stylesheet', function(arg, special){ if (!arg){ manager.list(false); return; } if (special){ manager.unload(arg) && echo('Unredisted '+arg); } else { manager.load(arg) && echo('Redisted '+arg); } }, { completer: function(filter, special){ var list = getCSSFiles().map(function(file){ var name = file.leafName.replace(/\.css$/i, ''); return [name, sss.sheetRegistered(getURIFromName(name), sss.USER_SHEET) ? '*' : '']; }); if (!filter) return [0, list]; var candidates = []; list.forEach(function(item){ if (item[0].toLowerCase().indexOf(filter) == 0){ candidates.push(item); } }); return [0, candidates]; }, bang: true } ); var CSSData = {}; commands.addUserCommand(['hi[ghlight]'], 'temporary style changer', function(args){ if (args.length == 0){ var str = ['show highlight list']; for (let name in CSSData){ str.push('<span class="hl-Title">' + name + '</span>'); str.push(CSSData[name]); } echo(str.join('\n'), true); } else if (args.length == 1){ var arg = args[0]; if (arg == 'clear'){ for (let name in CSSData){ manager.unload(getURIFromCSS(CSSData[name])); delete CSSData[name]; } } else if (arg in CSSData){ echo('<span class="hl-Title">' + rel.args[0] + '</span>\n' + CSSData[rel.args[0]], true); } } else if (args.length > 1){ var groupName = args.shift(); if (groupName == 'clear'){ args.forEach(function(name){ if (name in CSSData){ manager.unload(getURIFromCSS(CSSData[name])); delete CSSData[name]; } }); } else { if (groupName in CSSData) manager.unload(getURIFromCSS(CSSData[groupName])); CSSData[groupName] = args.join(' '); manager.load(getURIFromCSS(CSSData[groupName])); } } }, { completer: function(context, args){ var list1 = [['clear', 'clear all or specified group']]; var list2 = []; if (!args){ for (let name in CSSData){ list2.push([name, CSSData[name]]); } return [0, list1.concat(list2)]; } if (args.length == 2 && args[0] == 'clear'){ for (let name in CSSData){ if (name.indexOf(args[1]) == 0) list2.push([name, CSSData[name]]); } return [6, list2]; } else if (args.args.length == 1){ for (let name in CSSData){ if (name.indexOf(args[0]) == 0) list2.push([name, CSSData[name]]); } if ('clear'.indexOf(args[0]) == 0) return [0, list1.concat(list2)]; else return [0, list2]; } }, argCount: '*' } ); init(); return manager; })(); })(); // vim: sw=4 ts=4 sts=0 fdm=marker: