MCPcopy Index your code
hub / github.com/Tampermonkey/tampermonkey / createScriptItem

Function createScriptItem

src/options.js:1485–1838  ·  view source on GitHub ↗
(i, tr, tabv)

Source from the content-addressed store, hash-verified

1483};
1484
1485var createScriptItem = function(i, tr, tabv) {
1486 if (!gCallbacks[i.id]) gCallbacks[i.id] = {};
1487
1488 // tab stuff for later use
1489 var tab;
1490 var scriptdetails;
1491 var use_icon = i.icon && !i.nativeScript;
1492
1493 var sname = crc('span', 'script_name' + (i.nativeScript ? '' : ' clickable'), i.name, i.id, 'sname');
1494 var sname_img = crc('img', 'nameNicon16 icon16', i.name, i.id, 'sname_img');
1495
1496 var sname_name = crc('span', use_icon ? 'nameNname16': '', i.name, i.id, 'sname_name');
1497 var hp = i.homepage ? i.homepage : (i['namespace'] && i['namespace'].search('http://') == 0 ? i['namespace'] : null)
1498
1499 sname_name.textContent = (i.name.length > 35 ? i.name.substr(0,35) + '...' : i.name);
1500
1501 var sversion = cr('span', i.name, i.id, 'sversion');
1502 sversion.textContent = i.version ? i.version : '';
1503
1504 if (use_icon) {
1505 sname_img.src = i.icon;
1506 sname.appendChild(sname_img);
1507 }
1508
1509 var ret = [];
1510
1511 var getTD = function(i, child, app, clas) {
1512 if (!clas) clas = 'scripttd';
1513 var td1 = crc('td', clas, i.name, i.id, app)
1514 if (child) td1.appendChild(child);
1515 return td1;
1516 };
1517
1518 var closeAndRemoveTab = function() {
1519 if (tab) {
1520 tab.remove();
1521 tab = null;
1522 }
1523 };
1524
1525 var removeScriptItem = function() {
1526 sname.parentNode.removeChild(sname);
1527 // sname_name.setAttribute('open', 'false');
1528 };
1529
1530 var doRecreateScriptItem = function() {
1531 var run = function() {
1532 for (var o in allItems) {
1533 var c = allItems[o];
1534 if (c.id == i.id &&
1535 c.name == i.name) {
1536 // recreate editor
1537 createScriptItem(c, tr, tabv);
1538 break;
1539 }
1540 }
1541 }
1542 window.setTimeout(run, 1);

Callers 2

itemsToMenuFunction · 0.70
runFunction · 0.70

Calls 14

crcFunction · 0.85
crFunction · 0.85
gCbFunction · 0.85
modifyNativeScriptOptionFunction · 0.85
saveScriptFunction · 0.85
createEnableImageTDFunction · 0.85
scriptClickFunction · 0.70
time_betweenFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…