-
Notifications
You must be signed in to change notification settings - Fork 23
/
SITEINFO_Writer.uc.js
643 lines (608 loc) · 21.1 KB
/
SITEINFO_Writer.uc.js
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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
// ==UserScript==
// @name SITEINFO_Writer.uc.js
// @description AutoPagerize の SITEINFO を書くためのスクリプト
// @namespace http://d.hatena.ne.jp/Griever/
// @author Griever
// @include main
// @compatibility Firefox 5 - firefox 23a1
// @charset UTF-8
// @version 下書き1
// @note 同步:增加下一页中文选择xpath By ywzhaiqi@gmail.com
// @note fix compatibility for firefox 23a1 by lastdream2013
// @note まだこれからつくり込む段階
// @note ツールメニューから起動する
// ==/UserScript==
(function(css){
if (window.siteinfo_writer) {
window.siteinfo_writer.destroy();
delete window.siteinfo_writer;
}
window.siteinfo_writer = {
init: function() {
this.style = addStyle(css);
var overlay = '\
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" \
xmlns:html="http://www.w3.org/1999/xhtml"> \
<window id="main-window">\
<vbox id="sw-container" class="sw-add-element" hidden="true">\
<hbox id="sw-hbox">\
<toolbarbutton label="查看规则(AutoPagerize格式)" oncommand="siteinfo_writer.toJSON();"/>\
<toolbarbutton label="查看规则(super_preloader格式)" oncommand="siteinfo_writer.toSuperPreLoaderFormat();"/>\
<toolbarbutton id="sw-launch" label="启动规则" tooltiptext="启动uAutoPagerize" oncommand="siteinfo_writer.launch();"/>\
<spacer flex="1"/>\
<toolbarbutton class="tabs-closebutton" oncommand="siteinfo_writer.hide();"/>\
</hbox>\
<grid id="sw-grid">\
<columns>\
<column />\
<column flex="1"/>\
<column />\
<column />\
</columns>\
<rows>\
<row>\
<label value="siteName" />\
<textbox id="sw-siteName"/>\
<hbox />\
<toolbarbutton class="inspect"\
tooltiptext="提取网站名称"\
oncommand="siteinfo_writer.siteName.value = content.document.title;"/>\
</row>\
<row>\
<label value="url" />\
<textbox id="sw-url" oninput="siteinfo_writer.onInput(event);"/>\
<hbox />\
<toolbarbutton class="inspect"\
tooltiptext="提取地址"\
oncommand="siteinfo_writer.setUrl();"/>\
</row>\
<row>\
<label value="nextLink" />\
<textbox id="sw-nextLink" multiline="true"/>\
<toolbarbutton class="check"\
tooltiptext="测试XPath"\
oncommand="siteinfo_writer.xpathTest(\'nextLink\');"/>\
<toolbarbutton class="inspect"\
tooltiptext="提取XPath"\
oncommand="siteinfo_writer.inspect(\'nextLink\');"/>\
</row>\
<row>\
<label value="pageElement" />\
<textbox id="sw-pageElement" multiline="true"/>\
<toolbarbutton class="check"\
tooltiptext="测试XPath"\
oncommand="siteinfo_writer.xpathTest(\'pageElement\');"/>\
<toolbarbutton class="inspect"\
tooltiptext="提取XPath"\
oncommand="siteinfo_writer.inspect(\'pageElement\');"/>\
</row>\
<row>\
<label value="insertBefore" />\
<textbox id="sw-insertBefore" multiline="true"/>\
<toolbarbutton class="check"\
tooltiptext="测试XPath"\
oncommand="siteinfo_writer.xpathTest(\'insertBefore\');"/>\
<toolbarbutton class="inspect"\
tooltiptext="提取XPath"\
oncommand="siteinfo_writer.inspect(\'insertBefore\');"/>\
</row>\
</rows>\
</grid>\
</vbox>\
</window>\
</overlay>';
overlay = "data:application/vnd.mozilla.xul+xml;charset=utf-8," + encodeURI(overlay);
window.userChrome_js.loadOverlay(overlay, window.siteinfo_writer);
},
observe : function (aSubject, aTopic, aData) {
if (aTopic == "xul-overlay-merged")
{
this.popup = $("mainPopupSet").appendChild($C("menupopup",
{
id : "sw-popup",
class : "sw-add-element",
}
));
var menuitem = $C("menuitem",
{
class : "sw-add-element",
label : "辅助查找翻页规则",
oncommand : "siteinfo_writer.show();",
}
);
$("devToolsSeparator").parentNode.insertBefore(menuitem, $("devToolsSeparator"));
setTimeout(function ()
{
if (!window.uAutoPagerize)
{
$("sw-launch").hidden = true;
return;
};
let aupPopup = $("uAutoPagerize-popup");
if (aupPopup)
{
aupPopup.appendChild(document.createElement("menuseparator")).setAttribute("class", "sw-add-element");
aupPopup.appendChild(menuitem.cloneNode(false));
}
}, 2000);
this.container = $("sw-container");
this.url = $("sw-url");
this.siteName = $("sw-siteName");
this.nextLink = $("sw-nextLink");
this.pageElement = $("sw-pageElement");
this.insertBefore = $("sw-insertBefore");
this.nextLink.addEventListener("popupshowing", siteinfo_writer.pps, false);
this.pageElement.addEventListener("popupshowing", siteinfo_writer.pps, false);
this.insertBefore.addEventListener("popupshowing", siteinfo_writer.pps, false);
}
},
uninit : function () {
},
pps: function(event) {
event.currentTarget.removeEventListener(event.type, arguments.callee, false);
var popup = event.originalTarget;
var type = event.currentTarget.id.replace("sw-", "");
popup.appendChild($C("menuseparator",{}));
popup.appendChild($C("menuitem", {
label: '@class="xxx" → contains()',
oncommand: "siteinfo_writer.class2contains('"+ type +"');",
}));
popup.appendChild($C("menuitem",{
label: 'contains() → @class="xxx"',
oncommand: "siteinfo_writer.contains2class('"+ type +"');",
}));
},
destroy: function() {
$A(document.getElementsByClassName("sw-add-element")).forEach(function(e){
e.parentNode.removeChild(e);
})
this.style.parentNode.removeChild(this.style);
},
setUrl: function() {
this.url.value = "^" + content.location.href.replace(/[()\[\]{}|+.,^$?\\]/g, '\\$&');
this.url.className = "";
},
show: function() {
this.setUrl();
this.siteName.value = content.document.title;
this.nextLink.value = "";
this.pageElement.value = "";
this.insertBefore.value = "";
this.container.hidden = false;
},
hide: function() {
this.container.hidden = true;
},
toJSON: function() {
var json = "\t{\n";
json += "\t\tsiteName : '" + this.siteName.value + "',\n";
json += "\t\turl : '" + this.url.value.replace(/\\/g, "\\\\") + "',\n";
json += "\t\tnextLink : '" + this.nextLink.value + "',\n";
json += "\t\tpageElement : '" + this.pageElement.value + "',\n";
if ( this.insertBefore.value != '' ) {json += "\t\tinsertBefore: '" + this.insertBefore.value + "',\n";}
json += "\t\texampleUrl : '" + content.location.href + "',\n";
json += "\t},";
var r=confirm("翻页规则(按OK键将其复制到剪贴板):"+'\n\n' + json);
if(r==true){
try{
Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper).copyString(json);
}
catch(e){
alert(e);
}
}
},
toSuperPreLoaderFormat: function() {
var spdb = "\t{\n";
spdb += "\t\tsiteName : '" + this.siteName.value + "',\n";
spdb += "\t\turl : /" + this.url.value.replace(/\//g, "\\\/") + "/i,\n";
spdb += "\t\tsiteExample : '" + content.location.href + "',\n";
spdb += "\t\tnextLink : '" + this.nextLink.value + "',\n";
spdb += "\t\tautopager: {\n";
spdb += "\t\t\tuseiframe : true,\n";
spdb += "\t\t\tpageElement : '" + this.pageElement.value + "',\n";
if ( this.insertBefore.value != '' ) {spdb += "\t\t\tHT_insert : ['" + this.insertBefore.value + "', 1],\n";}
spdb += "\t\t}\n";
spdb += "\t},";
var r=confirm("翻页规则(SuperPreLoader格式)(按OK键将其复制到剪贴板):"+'\n\n' + spdb);
if(r==true){
try{
Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper).copyString(spdb);
}
catch(e){
alert(e);
}
}
},
launch: function() {
if (content.ap) return alert("已经运行");
var i = {};
["url", "nextLink", "pageElement", "insertBefore"].forEach(function(type) {
if (this[type].value)
i[type] = this[type].value
}, this);
if (!i.url || !i.nextLink || !i.pageElement)
return alert("指定的值无效");
let [index, info] = uAutoPagerize.getInfo([i], content);
if (index === 0) {
if (content.AutoPagerize && content.AutoPagerize.launchAutoPager)
content.AutoPagerize.launchAutoPager([i]);
else alert("翻页规则语法正确,但uAutoPagerize无法执行,可能uAutoPagerize被禁用或没有安装脚本");
} else {
alert("翻页规则不匹配");
}
},
inspect: function(aType) {
if (this._inspect)
this._inspect.uninit();
var self = this;
this._inspect = new Inspector(content, function(xpathArray) {
if (xpathArray.length) {
let range = document.createRange();
range.selectNodeContents(self.popup);
range.deleteContents();
range.detach();
for (let [i, x] in Iterator(xpathArray)) {
let menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", x);
menuitem.setAttribute("oncommand", "siteinfo_writer['"+ aType +"'].value = this.getAttribute('label')");
self.popup.appendChild(menuitem);
}
self.popup.openPopup(self.container, "before_start");
}
self._inspect = null;
});
},
xpathTest: function(aType) {
var textbox = this[aType]
if (!textbox || !textbox.value) return;
try {
var elements = getElementsByXPath(textbox.value, content.document);
} catch (e) {
alert(e);
}
for (let [i, elem] in Iterator(elements)) {
if (!("orgcss" in elem))
elem.orgcss = elem.style.cssText;
elem.style.backgroundImage = "-moz-linear-gradient(magenta, plum)";
elem.style.outline = "1px solid magenta";
}
var self = this;
if (this.timer) {
clearTimeout(this.timer);
this.timer = null;
}
this.timer = setTimeout(function() {
for (let [i, elem] in Iterator(elements)) {
if ("orgcss" in elem) {
elem.orgcss?
elem.style.cssText = elem.orgcss:
elem.removeAttribute("style");
delete elem.orgcss;
}
}
}, 5000);
},
urlTest: function() {
var url = this.url.value;
try {
var regexp = new RegExp(this.url.value);
if (regexp.test(content.location.href))
this.url.classList.remove("error");
else
this.url.classList.add("error");
} catch (e) {
this.url.classList.add("error");
}
},
inputTimer: null,
onInput: function(event) {
if (this.inputTimer) {
clearTimeout(this.inputTimer);
}
var self = this;
this.inputTimer = setTimeout(function() {
self.urlTest();
}, 100);
},
class2contains: function(aType) {
this[aType].value = this.splitClass(this[aType].value);
},
contains2class: function(aType) {
this[aType].value = this.normalClass(this[aType].value);
},
splitClass: function(xpath) {
return xpath.replace(/@class=\"(.+?)\"/g, function(str, cls) {
cls = cls.replace(/\s+/g, " ").replace(/^\s+|\s+$/g, "").split(" ");
for (var i = 0, l = cls.length; i < l; i++) {
cls[i] = 'contains(concat(" ",normalize-space(@class)," "), " '+ cls[i] +' ")';
}
return cls.join(" and ");
});
},
normalClass: function(xpath) {
let r = /(?:contains\(concat\(\" \"\,normalize\-space\(@class\)\,\" \"\)\, \" .+? \"\)(?: and )?)+/g;
return xpath.replace(r, function(str) {
let cls = str.split(' and ').map(function(c) c.replace(/.*\" (.*) \".*/i, '$1') );
return '@class="'+ cls.join(' ') +'"';
});
},
};
window.siteinfo_writer.init();
function Inspector(aWindow, aCallback) {
this.win = aWindow;
this.doc = this.win.document;
this.callback = aCallback;
this.init();
}
Inspector.prototype = {
init : function(){
this.doc.addEventListener('mousedown', this, true);
this.doc.addEventListener('click', this, true);
this.doc.addEventListener('mouseover', this, true);
},
uninit : function(){
var self = this;
this.lowlight();
this.doc.removeEventListener('mouseover', this, true);
setTimeout(function(){
self.doc.removeEventListener('mousedown', self, true);
self.doc.removeEventListener('click', self, true);
}, 500);
XULBrowserWindow.statusTextField.label = "";
},
handleEvent : function(event){
switch(event.type){
case 'mousedown':
event.preventDefault();
event.stopPropagation();
this.uninit();
if (event.button == 0)
this.callback(this.getXPath(this.target));
break;
case 'mouseover':
if (this.target)
this.lowlight();
this.target = event.target;
this.highlight();
break;
case "click":
event.preventDefault();
event.stopPropagation();
break;
}
},
highlight : function(){
if (this.target.mozMatchesSelector('html, body'))
return;
if (!("orgcss" in this.target))
this.target.orgcss = this.target.style.cssText;
this.target.style.outline = "magenta 2px solid";
this.target.style.outlineOffset = "-1px";
XULBrowserWindow.statusTextField.label = this.getElementXPath(this.target, this.ATTR_FULL);
},
lowlight : function() {
if ("orgcss" in this.target) {
this.target.orgcss?
this.target.style.cssText = this.target.orgcss:
this.target.removeAttribute("style");
delete this.target.orgcss;
}
},
ATTR_CLASSID: 0,
ATTR_ID: 1,
ATTR_CLASS: 2,
ATTR_NOT_CLASSID: 3,
ATTR_FULL: 4,
TEXT: 5,
NEXT_REG: /[下后][一]?[页张个篇章节步]/,
NEXT_REG_A: /^[下后][一]?[页张个篇章节步]$/,
getXPath: function(originalTarget) {
var nodes = getElementsByXPath(
'ancestor-or-self::*[not(local-name()="html" or local-name()="HTML" or local-name()="body" or local-name()="BODY")]', originalTarget).reverse();
if (nodes.length == 0) return [];
var current = nodes.shift();
var obj = {};
obj.localnames = current.localName;
obj.self_classid = this.getElementXPath(current, this.ATTR_CLASSID);
obj.self_id = this.getElementXPath(current, this.ATTR_ID);
obj.self_class = this.getElementXPath(current, this.ATTR_CLASS);
obj.self_attr = this.getElementXPath(current, this.ATTR_NOT_CLASSID);
obj.self_full = this.getElementXPath(current, this.ATTR_FULL);
obj.self_text = this.getElementXPath(current, this.TEXT);
obj.ancestor_classid = obj.self_classid;
obj.ancestor_id = obj.self_id;
obj.ancestor_class = obj.self_class;
obj.ancestor_attr = obj.self_attr;
obj.ancestor_full = obj.self_full;
obj.ancestor_text = obj.self_text;
var hasId = current.getAttribute("id");
for (let [i, elem] in Iterator(nodes)) {
obj.localnames = elem.localName + "/" + obj.localnames;
if (!hasId) {
hasId = elem.getAttribute("id");
obj.ancestor_classid = this.getElementXPath(elem, this.ATTR_CLASSID) + "/" + obj.ancestor_classid;
obj.ancestor_id = this.getElementXPath(elem, this.ATTR_ID) + "/" + obj.ancestor_id;
obj.ancestor_full = this.getElementXPath(elem, this.ATTR_FULL) + "/" + obj.ancestor_full;
obj.ancestor_text = this.getElementXPath(elem, this.ATTR_ID) + "/" + obj.ancestor_text;
}
obj.ancestor_class = this.getElementXPath(elem, this.ATTR_NOT_CLASS) + "/" + obj.ancestor_class;
obj.ancestor_attr = this.getElementXPath(elem, this.ATTR_NOT_CLASSID) + "/" + obj.ancestor_attr;
}
for (let [key, val] in Iterator(obj)) {
if (val.substr(0, 4) !== 'id("')
obj[key] = val = "//" + val;
}
var res = [x for each(x in obj)].filter(function(e, i, a) a.indexOf(e) === i).sort(function(a, b){
let aa = a.substr(0, 4) == 'id("';
let bb = b.substr(0, 4) == 'id("';
if ((aa && bb) || (!aa && !bb))
return b.length - a.length;
return bb? 1 : -1;
});
//var res = [[x, obj[x]] for(x in obj)].sort(function([a,], [b,]) a >= b);
////inspectObject([x for each(x in res)]);
//res = [x for each([,x] in res)].filter(function(e, i, a) a.indexOf(e) === i);
////inspectObject(res);
return res;
},
getElementXPath: function(elem, constant) {
if (!elem.getAttribute)
return "";
if (this.ATTR_CLASSID == constant) {
if (elem.getAttribute("id"))
return 'id("'+ elem.getAttribute('id') +'")';
if (elem.getAttribute("class"))
return elem.nodeName.toLowerCase() + '[@class="' + elem.getAttribute("class") + '"]';
return elem.nodeName.toLowerCase();
}
if (this.ATTR_ID == constant) {
if (elem.getAttribute("id"))
return 'id("'+ elem.getAttribute('id') +'")';
return elem.nodeName.toLowerCase();
}
if (this.ATTR_CLASS == constant) {
if (elem.getAttribute("class"))
return elem.nodeName.toLowerCase() + '[@class="' + elem.getAttribute("class") + '"]';
return elem.nodeName.toLowerCase();
}
if(this.TEXT == constant){
var elemHtml = elem.textContent;
if(elemHtml.length < 20 && elemHtml.match(this.NEXT_REG)){
if(elemHtml.match(this.NEXT_REG_A)){
return elem.nodeName.toLowerCase() + '[text()="' + elemHtml + '"]';
}
return elem.nodeName.toLowerCase() + '[contains(text(), "' + elemHtml + '")]';
}
return elem.nodeName.toLowerCase();
}
var xpath = elem.nodeName.toLowerCase();
if (this.ATTR_FULL == constant) {
let x = [];
if (elem.hasAttribute("id"))
x[x.length] = '@id="' + elem.getAttribute("id") + '"';
if (elem.hasAttribute("class"))
x[x.length] = '@class="' + elem.getAttribute("class") + '"';
if (x.length)
xpath += '['+ x.join(" and ") +']';
}
/*
var attrs = elem.attributes;
var arr = [];
for (var i = 0, len = attrs.length; i < len; i++) {
var name = attrs[i].nodeName;
if (name === "style" || name === "id" || name === "class") continue;
var value = attrs[i].nodeValue;
arr[arr.length] = '@' + name + '="' + value + '"';
};
*/
var arr = [
"@"+ x.nodeName +'="'+ x.nodeValue +'"'
for each(x in $A(elem.attributes))
if (!/^(?:id|class|style)$/i.test(x.nodeName))
];
if (arr.length > 0)
xpath += '[' + arr.join(" and ") + ']';
return xpath;
},
};
function log(){ Application.console.log($A(arguments)); }
function $(id) document.getElementById(id);
function $A(arr) Array.slice(arr);
function $C(name, attr) {
var el = document.createElement(name);
if (attr) Object.keys(attr).forEach(function(n) el.setAttribute(n, attr[n]));
return el;
}
function addStyle(css) {
var pi = document.createProcessingInstruction(
'xml-stylesheet',
'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(css) + '"'
);
return document.insertBefore(pi, document.documentElement);
}
function getElementsByXPath(xpath, node) {
var nodesSnapshot = getXPathResult(xpath, node, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
var data = [];
for (var i = 0, l = nodesSnapshot.snapshotLength; i < l; i++) {
data[i] = nodesSnapshot.snapshotItem(i);
}
return data;
}
function getFirstElementByXPath(xpath, node) {
var result = getXPathResult(xpath, node, XPathResult.FIRST_ORDERED_NODE_TYPE);
return result.singleNodeValue;
}
function getXPathResult(xpath, node, resultType) {
var doc = node.ownerDocument || node
var resolver = doc.createNSResolver(node.documentElement || node)
// Use |node.lookupNamespaceURI('')| for Opera 9.5
var defaultNS = node.lookupNamespaceURI(null)
if (defaultNS) {
const defaultPrefix = '__default__'
xpath = addDefaultPrefix(xpath, defaultPrefix)
var defaultResolver = resolver
resolver = function (prefix) {
return (prefix == defaultPrefix)
? defaultNS : defaultResolver.lookupNamespaceURI(prefix)
}
}
return doc.evaluate(xpath, node, resolver, resultType, null)
}
function addDefaultPrefix(xpath, prefix) {
const tokenPattern = /([A-Za-z_\u00c0-\ufffd][\w\-.\u00b7-\ufffd]*|\*)\s*(::?|\()?|(".*?"|'.*?'|\d+(?:\.\d*)?|\.(?:\.|\d+)?|[\)\]])|(\/\/?|!=|[<>]=?|[\(\[|,=+-])|([@$])/g
const TERM = 1, OPERATOR = 2, MODIFIER = 3
var tokenType = OPERATOR
prefix += ':'
function replacer(token, identifier, suffix, term, operator, modifier) {
if (suffix) {
tokenType =
(suffix == ':' || (suffix == '::' &&
(identifier == 'attribute' || identifier == 'namespace')))
? MODIFIER : OPERATOR
}
else if (identifier) {
if (tokenType == OPERATOR && identifier != '*') {
token = prefix + token
}
tokenType = (tokenType == TERM) ? OPERATOR : TERM
}
else {
tokenType = term ? TERM : operator ? OPERATOR : MODIFIER
}
return token
}
return xpath.replace(tokenPattern, replacer)
};
})('\
\
#sw-grid row > label {\
margin: 1px !important;\
}\
#sw-grid row > textbox {\
-moz-appearance: none !important;\
margin: 1px !important;\
padding: 1px !important;\
border-width: 1px !important;\
}\
#sw-grid row > textbox[multiline="true"] {\
height: 4em;\
}\
\
#sw-grid .inspect {\
list-style-image: url("chrome://global/skin/icons/Search-glass.png");\
-moz-image-region: rect(0px, 16px, 16px, 0px);\
}\
\
#sw-grid .check {\
list-style-image: url("chrome://global/skin/icons/find.png");\
-moz-image-region: rect(0px, 48px, 16px, 32px);\
}\
\
#sw-url.error {\
outline: 1px solid red !important;\
}\
#sw-popup > * {\
max-width: none !important;\
}\
');