MCPcopy Create free account
hub / github.com/Tampermonkey/tampermonkey / createActionsMenu

Function createActionsMenu

src/action.js:22–190  ·  view source on GitHub ↗
(items)

Source from the content-addressed store, hash-verified

20var I18N = Registry.get('i18n');
21
22var createActionsMenu = function(items) {
23 var action = document.getElementById('action');
24 var p = action.parentNode;
25 p.removeChild(action);
26 action = cr('span');
27 action.setAttribute("id", "action");
28 p.appendChild(action);
29
30 var table = crc('table', 'actiontable', 'actiontable');
31
32 for (var k in items) {
33 var i = items[k];
34 var tr = crc('tr', 'actiontr');
35 var span;
36 var image;
37
38 if (i.divider) {
39 var t = crc('tr', 'filler');
40 var d = crc('td', 'filler ');
41 d.setAttribute('colspan', '3');
42 var s = crc('div', 'actiondivider', 'divider', k.toString());
43 d.appendChild(s);
44 t.appendChild(d);
45 table.appendChild(t);
46 } else {
47 var td1 = crc('td', 'imagetd actionimagetd');
48 var td2 = crc('td', 'actiontd');
49 var ai2 = crc('div', 'actionitem', i.name, i.id, 'ai', true);
50 td2.appendChild(ai2);
51
52 if (i.image) {
53 image = HtmlUtil.createImage(i.image, i.name, i.id, null, "");
54 td1.appendChild(image);
55 }
56
57 if (i.checkbox) {
58 var input = document.createElement('input');
59 input.type = "checkbox";
60 input.name = i.name;
61 input.id = 'enabled';
62 input.checked = i.enabled;
63 var oc = function() {
64 modifyScriptOptions(this.name, this.id, this.checked);
65 }
66 input.addEventListener("click", oc);
67 span = document.createElement('span');
68 span.textContent = i.name;
69 ai2.appendChild(input);
70 ai2.appendChild(span);
71 } else if (i.url || i.urls) {
72 var rs = i.urls || [ i ];
73 td2.setAttribute("colspan", "2");
74 for (var f=0; f<rs.length; f++) {
75 var j = rs[f];
76 span = document.createElement('a');
77 span.href = 'javascript://nop/';
78 span.url = j.url;
79 span.newtab = j.newtab;

Callers 2

modifyScriptOptionsFunction · 0.85
action.jsFile · 0.85

Calls 3

crFunction · 0.85
crcFunction · 0.85
processFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…