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

Function createImagesFromScript

src/options.js:1999–2121  ·  view source on GitHub ↗
(i)

Source from the content-addressed store, hash-verified

1997};
1998
1999var createImagesFromScript = function(i) {
2000 var span = cr('span', i.name, i.id, 'site_images');
2001 var oldspan = null;
2002 if (span.inserted) {
2003 // cache image sif possible, but remove not used though
2004 oldspan = span;
2005 oldspan.setAttribute('id', oldspan.id + "foo");
2006 span = cr('span', i.name, i.id, 'site_images');
2007 }
2008
2009 var getInfo = function(inc) {
2010 inc = inc.replace(/^\*:\/\//, 'http://');
2011 if (inc.search("http") != 0) inc = "http://" + inc;
2012 var sl = inc.split('/');
2013 if (sl.length < 3) return null;
2014 var ps = sl[2].split('.');
2015 if (ps.length < 2) return null;
2016 var tld = ps[ps.length-1];
2017 var dom = ps[ps.length-2];
2018 var predom = [];
2019 for (var t=ps.length-3; t>=0; t--) {
2020 if (ps[t].search('\\*') != -1) break;
2021 predom.push(ps[t]);
2022 }
2023 return {tld: tld, dom: dom, predom: predom.reverse()};
2024 };
2025
2026 if (i.includes || i.matches) {
2027 var d = 0;
2028 var incl = i.includes.length ? i.includes : i.matches;
2029 for (var o=0; o<incl.length;o++) {
2030 var inc = incl[o];
2031 if (!inc) {
2032 console.log("o: Warn: script '" + i.name + "' has invalid include (index: " + o + ")");
2033 continue; // issue 93 ?!
2034 }
2035
2036 if (inc.search(/htt(ps|p):\/\/(\*\/\*|\*)*$/) != -1 ||
2037 inc.search(/\*:\/\/(\*\/\*|\*)*$/) != -1 ||
2038 inc == "*") {
2039 var img = HtmlUtil.createImage(chrome.extension.getURL('images/web.png'),
2040 i.name,
2041 i.id,
2042 inc,
2043 inc);
2044 span.appendChild(img);
2045 break;
2046 continue;
2047 }
2048
2049 var inf = getInfo(inc);
2050 if (inf == null) {
2051 var img = HtmlUtil.createFavicon('?',
2052 i.name,
2053 i.id,
2054 inc,
2055 inc);
2056 if (img.inserted && oldspan) {

Callers 1

createScriptItemFunction · 0.70

Calls 3

crFunction · 0.85
crcFunction · 0.85
getInfoFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…