This file is indexed.

/usr/share/xul-ext/ubiquity/standard-feeds/general.js is in xul-ext-ubiquity 0.6.4~pre20140729-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
// -----------------------------------------------------------------
// TEXT COMMANDS
// -----------------------------------------------------------------

Cu.import("resource://gre/modules/Services.jsm")

var H = Utils.escapeHtml;

/* Note that these text formatting commands are a little weird in that
 * they operate on a selection, but they don't take the selection as
 * an argument.  This is as intended, because if there is no text
 * selection, there is nothing for any of these commands to do.
 */
(function textFormattingCommand(format, desc, icon, name) {
  var xxdo = /do$/.test(format), tag = format[0] + ">";
  CmdUtils.CreateCommand({
    names: [name || format],
    description: desc + ".",
    icon: "chrome://ubiquity/skin/icons/" + icon + ".png",
    execute: function txtfmt_execute() {
      var doc = context.focusedWindow.document;
      if (doc.designMode === "on")
        doc.execCommand(format, false, null);
      else if (xxdo)
        context.chromeWindow.document
          .getElementById("cmd_" + format).doCommand();
      else
        let (htm = "<" + tag + CmdUtils.htmlSelection + "</" + tag)
          CmdUtils.setSelection(htm, {text: htm});
    }
  });
  return arguments.callee;
})
("bold", "Makes the selected text bold", "text_bold")
("italic", "Makes the selected text italic", "text_italic", "italicize")
("underline", "Underlines the selected text", "text_underline")
("undo", "Undoes your latest style/formatting or page-editing changes",
 "arrow_undo", "undo text edit")
("redo", "Redoes your latest style/formatting or page-editing changes",
 "arrow_redo", "redo text edit")
;

CmdUtils.CreateCommand({
  names: ["highlight", "hilite"],
  description: (
    'Highlights your current selection, ' +
    'like <span style="background: yellow; color: black;">this</span>.'),
  icon: "chrome://ubiquity/skin/icons/textfield_rename.png",
  execute: function hilite_execute() {
    var win = context.focusedWindow;
    var doc = win.document;
    var sel = win.getSelection();
    for (var i = sel.rangeCount; i--;) {
      var range = sel.getRangeAt(i);
      var newNode = doc.createElement("span");
      var {style} = newNode;
      style.background = "yellow";
      style.color = "black";
      range.surroundContents(newNode);
    }
  }
});

const NUM_WORDS = _("${num} words.");

function wordCount(t) (t.match(/\S+/g) || "").length;

CmdUtils.CreateCommand({
  names: ["count words", "word count"],
  arguments: {object: noun_arb_text},
  icon: "chrome://ubiquity/skin/icons/sum.png",
  description: "Displays the number of words in a selection.",
  execute: function ({object: {text}}) {
    displayMessage(
      text
      ? _(NUM_WORDS, {num: wordCount(text)})
      : _("No words selected."),
      this);
  },
  preview: function (pb, {object: {text}}) {
    pb.innerHTML = (
      text
      ? _(NUM_WORDS, {num: "<strong>" + wordCount(text) + "</strong>"})
      : this.previewDefault());
  }
});

/* TODO the dummy argument "wikipedia" could become a plugin argument
 * and this command could become a general purpose "insert link"
 * command.
 */
CmdUtils.CreateCommand({
  names: ["link to Wikipedia"],
  arguments: {
    object: noun_arb_text,
    format: noun_type_lang_wikipedia,
  },
  description:
  "Turns a phrase into a link to the matching Wikipedia article.",
  icon: "chrome://ubiquity/skin/icons/wikipedia.ico",
  _link: function({object: {text, html}, format: {data}}){
    var url = ("http://" + (data || "en") +
               ".wikipedia.org/wiki/Special%3ASearch/" +
               encodeURIComponent(text.replace(/ /g, "_")));
    return ['<a href="' + Utils.escapeHtml(url) + '">' + html + "</a>", url];
  },
  execute: function (args) {
    var [htm, url] = this._link(args);
    CmdUtils.setSelection(htm, {text: url});
  },
  preview: function (pbl, args) {
    var [htm, url] = this._link(args);
    pbl.innerHTML =
      this.previewDefault() +
      (htm && "<p>" + htm + "</p><code>" + Utils.escapeHtml(url) + "</code>");
  }
});

// -----------------------------------------------------------------
// CALCULATE COMMANDS
// -----------------------------------------------------------------

const noun_calc = {
  label: "expression",
  suggest: function (txt, htm, cb, si) {
    if (!this._mathlike.test(txt)) return []
    try {
      var result = this.Parser.evaluate(txt)
        , score  = result === txt ? .3 : 1
    }
    catch (e) {
      result = e.message
      score  = .1
    }
    return [CmdUtils.makeSugg(txt, htm, result, score, si)];
  },
  _mathlike: /^[\w.+\-*\/^%(, )|]+$/,
}
Services.scriptloader.loadSubScript
("resource://ubiquity/scripts/math_parser.js", noun_calc)

CmdUtils.CreateCommand({
  names: "calculate",
  description:
    'Calculates using\
     <a href="http://silentmatt.com/javascript-expression-evaluator/">\
     JavaScript Expression Evaluator</a>.',
  help: "Try: <code>22/7, 3^4^5, sin(sqrt(log(PI)))</code>",
  icon: "chrome://ubiquity/skin/icons/calculator.png",
  author: "satyr",
  license: "Public domain",
  argument: noun_calc,
  execute: function ({object: {data, score}}) {
    if (score > .3) CmdUtils.setSelection(data)
    displayMessage(data)
  },
  preview: function (pb, {object: {data, score}}) {
    pb.innerHTML = (score < .3 ? "<em class=error>" : "<strong>") + data
  },
})

// -----------------------------------------------------------------
// TRANSLATE COMMANDS
// -----------------------------------------------------------------

const PREF_LANG_DEFAULT = "extensions.ubiquity.translate.lang.default"
    , PREF_LANG_ALT     = "extensions.ubiquity.translate.lang.alt"

const MS_TRANSLATOR_LIMIT = 1e4
    , MS_LANGS     = {}
    , MS_LANGS_REV =
      { ar: "Arabic"
      , bg: "Bulgarian"
      , ca: "Catalan"
      , cs: "Czech"
      , da: "Danish"
      , nl: "Dutch"
      , en: "English"
      , et: "Estonian"
      , fi: "Finnish"
      , fr: "French"
      , de: "German"
      , el: "Greek"
      , hi: "Hindi"
      , hu: "Hungarian"
      , id: "Indonesian"
      , it: "Italian"
      , ja: "Japanese"
      , ko: "Korean"
      , lv: "Latvian"
      , lt: "Lithuanian"
      , no: "Norwegian"
      , pl: "Polish"
      , pt: "Portuguese"
      , ro: "Romanian"
      , ru: "Russian"
      , sk: "Slovak"
      , sl: "Slovenian"
      , es: "Spanish"
      , sv: "Swedish"
      , th: "Thai"
      , tr: "Turkish"
      , uk: "Ukrainian"
      , vi: "Vietnamese"
      , "zh-CN": "Chinese Simplified"
      , "zh-TW": "Chinese Traditional"
      }
for (let [code, name] in Iterator(MS_LANGS_REV)) MS_LANGS[name] = code

function defaultLanguage(code2name, exclude) {
  for (let pref of [exclude ? PREF_LANG_ALT : PREF_LANG_DEFAULT,
                    "intl.accept_languages",
                    "general.useragent.locale"])
    for (let code of Utils.prefs.get(pref, "").split(",")) {
      if (!(code = code.trim())) continue
      code = (/^(..-)(..)$/i.test(code)
              ? RegExp.$1.toLowerCase() + RegExp.$2.toUpperCase()
              : code.slice(0, 2).toLowerCase())
      if (code === exclude) continue
      let name = code2name[code]
      if (name) return {name: name, code: code}
    }
  var fallback = exclude === "en" ? "ja" : "en"
  return {name: code2name[fallback], code: fallback}
}

function translate(target, from, to, back) {
  if (!to) return void
    msTranslator("Detect", {text: target.text}, function detected(code) {
      translate(target, from, defaultLanguage(MS_LANGS_REV, code).code, back)
    })
  var {html} = target
  // bitbucket#29: The API doesn't like apostrophes HTML-escaped.
  ~html.indexOf('<') || (html = html.replace(/&#39;/g, "'"))
  msTranslator("Translate", {
    contentType: "text/html", text: html, from: from, to: to,
  }, back)
}

function msTranslator(method, params, back) {
  params.appId = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ new Date % 10
  $.ajax({
    url: "http://api.microsofttranslator.com/V2/Ajax.svc/" + method,
    data: params,
    success : function mst_ok(json) { back(JSON.parse(json)) },
    error   : function mst_ng() {
      displayMessage({title: "Microsoft Translator", text: "(>_<)"})
    },
  })
}

CmdUtils.CreateCommand({
  name: "translate",
  description: "Translates from one language to another.",
  icon: "chrome://ubiquity/skin/icons/translate_bing.ico",
  help: '\
    You can specify the language to translate to,\
    and the language to translate from.\
    For example, try issuing "translate mother from english to chinese".\
    If you leave out the languages, it will try to guess what you want.\
    It works on selected text in any web page,\
    but there&#39;s a limit (a couple of paragraphs)\
    to how much it can translate a selection at once.\
    If you want to translate a lot of text, leave out the input and\
    it will load\
    <a href="http://www.microsofttranslator.com">Bing Translator</a> toolbar.\
  ',
  author: "satyr",
  arguments: let (noun = CmdUtils.NounType("language", MS_LANGS)) {
    object : noun_arb_text,
    source : noun,
    goal   : noun,
  },
  execute: function translate_execute({object, goal, source}) {
    var from = source.data || ""
      , to   = goal  .data
    if (object.text && object.text.length <= MS_TRANSLATOR_LIMIT)
      translate(object, from, to, CmdUtils.setSelection.bind(CmdUtils))
    else
      CmdUtils.injectJs(
        "http://labs.microsofttranslator.com/bookmarklet/default.aspx?f=js" +
        "&from=" + from +
        "&to=" + (to || defaultLanguage(MS_LANGS_REV).code))
  },
  preview: function translate_preview(pblock, {object, goal, source}) {
    var limitExceeded = object.text.length > MS_TRANSLATOR_LIMIT
    if (!object.text || limitExceeded) {
      let ph = _('\
        Loads <a href="http://www.microsofttranslator.com">Bing Translator</a>\
        toolbar.\
      ')
      if (limitExceeded)
        ph += '<p><em class="error">' +
          _("The text you selected exceeds the API limit.") +
        '</em>'
      pblock.innerHTML = ph
      return
    }
    var name = goal.text
      , phtml = _("Translates the selected text:")
    pblock.innerHTML = phtml + " ..."
    translate(
      object, source.data || "", goal.data,
      CmdUtils.previewCallback(pblock, function show(html) {
        pblock.innerHTML = phtml + "<br><br>" + html
      }))
  },
  _getUrl: function translate_getUrl() noun_type_url.default()[0].text,
})

CmdUtils.CreateCommand({
  names: ["translate page", "Google Translate"],
  description: '\
    Translates a whole page to the specified language using\
    <a href="http://translate.google.com">Google Translate</a>.\
  ',
  icon: "chrome://ubiquity/skin/icons/translate_google.ico",
  author: "satyr",
  arguments: {
    object : noun_type_url,
    goal   : noun_type_lang_google,
  },
  execute: function gtranslate_execute({object, goal}) {
    Utils.openUrlInBrowser(
      "http://translate.google.com/translate" +
      Utils.paramsToString({
        u  : object.text,
        tl : goal.data ||
             defaultLanguage(noun_type_lang_google._code2name).code,
      }))
  },
  preview: function gtranslate_preview(pb, {object, goal}) {
    pb.innerHTML =
      _("Translates <code>${url}</code> to <strong>${language}</strong>.", {
        url      : Utils.escapeHtml(object.text),
        language : goal.text ||
                   defaultLanguage(noun_type_lang_google._code2name).name,
      })
  },
})

// -----------------------------------------------------------------
// COMMANDS THAT CREATE NEW COMMANDS
// -----------------------------------------------------------------

/* TODO: This command should take another optional argument to
 * provides an alternate name for the new command. */

/* TODO combine both of these into a single command with a provider
 * plugin?  i.e. "create command using/with/from bookmarklet",
 * "create command using/with/from search box"
 */
CmdUtils.CreateCommand({
  names: ["create bookmarklet command"],
  arguments: [{role: "source", nountype: noun_type_bookmarklet}],
  description: "Creates a new Ubiquity command from a bookmarklet.",
  help: ("For instance, if you have a bookmarklet called 'press this', " +
         "you can say 'create bookmarklet command from press this'."),
  author: {name: "Abimanyu Raja", email: "abimanyuraja@gmail.com"},
  license: "MPL",
  preview: function(previewBlock, {source: {text, data}}) {
    previewBlock.innerHTML =
      data
      ? 'Creates a new command called<b>'+ H(this._formatName(text)) +
        '</b> that runs the following bookmarklet:'+
        '<pre style="white-space:pre-wrap">'+ H(decodeURI(data)) +'</pre>'
      : this.description;
  },
  execute: function({source}) {
    var name = this._formatName(source.text);
    var url = source.data;

    //build the piece of code that creates the command
    var code =  [
      "// generated by " + this.name,
      "CmdUtils.makeBookmarkletCommand({",
      "  name: " + uneval(name) + ",",
      "  url: " + uneval(url) + ",",
      "});\n\n",
      ].join("\n");

    //prepend the code to Ubiqity's command editor
    CmdUtils.UserCode.prependCode(code);

    tellTheUserWeFinished(name, this);
  },
  _formatName: function(n) n.toLowerCase(),
});

CmdUtils.CreateCommand({
  names: ["create search command"],
  description: ("Creates a new Ubiquity command from a focused search-box " +
                "and lets you set the command name."),
  help: '<ol style="list-style-image:none">\
         <li>Select a searchbox.</li>\
         <li>Say "create search command mysearch".</li>\
         <li>Execute.</li>\
         <li>You now have a command called "mysearch".</li>\
         </ol>',
  author:
  {name: "Marcello Herreshoff", homepage: "http://stanford.edu/~marce110/"},
  contributors: ["Abimanyu Raja", "satyr"],
  icon: "chrome://ubiquity/skin/icons/search.png",
  license: "GPL/LGPL/MPL",
  homepage:
  "http://stanford.edu/~marce110/verbs/new-command-from-search-box.html",
  arguments: [{
    role: "object",
    nountype: noun_arb_text,
    label: "command name"}],
  preview: function csc_preview(pblock, {object: {html}}) {
    pblock.innerHTML = (
      html
      ? _("Creates a new search command called <b>${text}</b>", {text: html})
      : this.previewDefault());
  },
  execute: function csc_execute({object: {text: name}}) {
    var node = context.focusedElement || 0;
    var {form} = node;
    if (!node || !form) {
      displayMessage(
        _("You need to focus a searchbox before running this command."));
      return;
    }
    //1. Figure out what this searchbox does.
    const PLACEHOLDER = "{QUERY}";
    var formData = [];
    Array.forEach(form.elements, function(el) {
      if (!el.type) return; // happens with fieldsets
      if (el === node) {
        formData.push(this._encodePair(el.name, "") + PLACEHOLDER);
        return;
      }
      var type = el.type.toLowerCase();
      if (/^(?:text(?:area)?|hidden)$/.test(type) ||
          /^(?:checkbox|radio)$/.test(type) && el.checked)
        formData.push(this._encodePair(el.name, el.value));
      else if (/^select-(?:one|multiple)$/.test(type))
        Array.forEach(el.options, function(o) {
          if (o.selected)
            formData.push(this._encodePair(el.name, o.value));
        }, this);
    }, this);
    var doc = node.ownerDocument;
    var uri = Utils.url({uri: form.getAttribute("action"), base: doc.URL});
    var url = uri.spec;
    var data = formData.join("&");
    var post = form.method.toUpperCase() === "POST";
    if (!post) url += "?" + data;

    //2. Generate the name if not specified.
    if (!name) name = uri.host || doc.title;

    //3. Build the piece of code that creates the command
    var codes = [];
    codes.push(
      "// generated by " + this.name,
      "CmdUtils.makeSearchCommand({",
      "  name: " + uneval(name) + ",",
      "  url: " + uneval(url) + ",");
    doc.characterSet !== "UTF-8" && codes.push(
      "  charset: " + uneval(doc.characterSet) + ",");
    post && codes.push(
      "  postData: " + uneval(data) + ",");
    codes.push(
      "});\n\n");

    //4. Prepend the code to command-editor
    CmdUtils.UserCode.prependCode(codes.join("\n"));

    //5. Tell the user we finished
    tellTheUserWeFinished(name, this);
  },
  _encodePair: function csc__encodePair(key, val)
    encodeURIComponent(key) + "=" + encodeURIComponent(val),
});

const MSG_CREATED = _("You have created the command: [ ${name} ]. " +
                      "You can edit its source-code with the command editor.");

function tellTheUserWeFinished(name, cmd) {
  displayMessage(CmdUtils.renderTemplate(MSG_CREATED, {name: name}),
                 cmd);
}