MCPcopy
hub / github.com/Tampermonkey/tampermonkey / createUtilTab

Function createUtilTab

src/options.js:457–718  ·  view source on GitHub ↗
(tabv)

Source from the content-addressed store, hash-verified

455};
456
457var createUtilTab = function(tabv) {
458 var i = {name: 'utils', id: 'utils'};
459
460 var h = cr('div', i.name, i.id, 'tab_util_h');
461 h.textContent = I18N.getMessage('Utilities');
462 var util = cr('div', i.name, i.id, 'tab_util');
463 var tab = tabv.appendTab(Helper.createUniqueId(i.name, i.id), h, util);
464
465 // TODO: hardcoded !!
466 if (50 > gOptions.configMode) {
467 tab.hide();
468 } else {
469 tab.show();
470 }
471
472 var cont = crc('div', 'tv_util', i.name, i.id, 'tab_util_cont');
473
474 var expo = function() {
475 var exp = { 'created_by' : 'Tampermonkey', 'version' : '1', scripts: [] };
476
477 for (var o in allItems) {
478 var c = allItems[o];
479 if ((c.userscript || i.user_agent) && c.id && !c.system) {
480 var p = { name: c.name, options: c.options, enabled: c.enabled, position: c.position };
481 if (c.file_url && c.file_url.trim() != "") {
482 p.file_url = c.file_url;
483 }
484 if (c.code && c.code.trim() != "" ){
485 p.source = Converter.Base64.encode(Converter.UTF8.encode(c.code));
486 exp.scripts.push(p);
487 } else {
488 console.log("options: Strange script: " + c.name);
489 }
490 }
491 }
492
493 return JSON.stringify(exp);
494 };
495
496 var impo = function(src) {
497 var err = false;
498 var cnt = 0;
499 if (src.trim() != "") {
500 var m = null;
501 try {
502 m = JSON.parse(src);
503 } catch (e) {
504 var t1 = '<body>';
505 var t2 = '</body>';
506 if (src.search(t1) != -1) {
507 var p1 = src.indexOf(t1);
508 var p2 = src.lastIndexOf(t2);
509 if (p1 != -1 && p2 != -1) {
510 src = src.substr(p1 + t1.length, p2 - (p1 + t1.length));
511 impo(src);
512 }
513 } else {
514 Helper.alert(I18N.getMessage('Unable_to_parse_this_'));

Callers 1

createOptionsMenuFunction · 0.85

Calls 2

crFunction · 0.85
crcFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…