Skip to content

Instantly share code, notes, and snippets.

@dzfl
Created November 20, 2012 07:35
Show Gist options
  • Save dzfl/4116593 to your computer and use it in GitHub Desktop.
Save dzfl/4116593 to your computer and use it in GitHub Desktop.
addMenu.uc.js to Everything Patch
page({
label: "Search Everything",
text: " -search \"%s\"",
exec: "C:\\path\\to\\Everything.exe",
condition: "select"
});
--- addMenu.uc.js 2012-11-20 19:07:58.197624400 +0900
+++ addMenu.uc.js 2012-11-20 19:06:47.544370300 +0900
@@ -269,7 +269,27 @@
var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
try {
+ // to Everything
+ arg = arg.replace(
+ /\"(.*?)\"/g,
+ function (whole,s1) {
+ return( s1.replace(/\s+/g, "__SPACE__") );
+ }
+ );
+ // to Everything end
+
var a = (typeof arg == 'string' || arg instanceof String) ? arg.split(/\s+/) : [arg];
+
+ // to Everything
+ var UI = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
+ UI.charset = window.navigator.platform.toLowerCase().indexOf("win") >= 0? "Shift_JIS": "UTF-8";
+ arg = UI.ConvertFromUnicode(arg) + UI.Finish();
+ for(var i in a){
+ a[i] = UI.ConvertFromUnicode(a[i])
+ a[i] = a[i].replace(/__SPACE__/g, " ");
+ }
+ // to Everything end
+
file.initWithPath(path);
process.init(file);
process.run(false, a, a.length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment