GreenLunar Author

Solved

function loadXMLDoc(filename)
{
xhttp = new XMLHttpRequest();
xhttp.open("GET", filename, false);
xhttp.send("");
return xhttp.responseXML;
}

function displayResult()
{
xml = loadXMLDoc(location.href);
xsl = loadXMLDoc("http://localhost:8000/cdcatalog.xsl");
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToDocument(xml);
}

displayResult()

window.content  = resultDocument;

document.replaceChild (
    document.importNode (resultDocument.documentElement, true),
    document.documentElement
);

Solved

function loadXMLDoc(filename)
{
xhttp = new XMLHttpRequest();
xhttp.open("GET", filename, false);
xhttp.send("");
return xhttp.responseXML;
}

function displayResult()
{
xml = loadXMLDoc(location.href);
xsl = loadXMLDoc("http://localhost:8000/cdcatalog.xsl");
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToDocument(xml);
}

displayResult()

window.content  = resultDocument;

document.replaceChild (
    document.importNode (resultDocument.documentElement, true),
    document.documentElement
);


The following code made the error disappear but the XML file is still not transformed...

const stylesheet = document.createElement('div');
document.getElementsByTagName('div')[0].appendChild(resultDocument);

location.href is http://localhost:8000/cdcatalog.xml

Userscript file:

function loadXMLDoc(filename)
{
xhttp = new XMLHttpRequest();
xhttp.open("GET", filename, false);
xhttp.send("");
return xhttp.responseXML;
}

function displayResult()
{
xml = loadXMLDoc(location.href);
xsl = loadXMLDoc("http://localhost:8000/cdcatalog.xsl");
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml, document);
}

displayResult()

XML file

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <cd>
    <title>QupZilla</title>
    <artist>David Rosca</artist>
    <country>CZ</country>
    <company>QtWebKit</company>
    <price>10.90</price>
    <year>2010</year>
  </cd>
  <cd>
    <title>QupZilla C++</title>
    <artist>David Rosca</artist>
    <country>CZ</country>
    <company>QtWebKit</company>
    <price>10.90</price>
    <year>2012</year>
  </cd>
  <cd>
    <title>QupZilla Leaving PyQt4</title>
    <artist>David Rosca</artist>
    <country>CZ</country>
    <company>QtWebKit</company>
    <price>10.90</price>
    <year>2012</year>
  </cd>
  <cd>
    <title>QupZilla The Return Of The Python</title>
    <artist>David Rosca</artist>
    <country>CZ</country>
    <company>QtWebKit</company>
    <price>10.90</price>
    <year>2012</year>
  </cd>
  <cd>
    <title>Falkon</title>
    <artist>David Rosca</artist>
    <country>CZ</country>
    <company>KDE</company>
    <price>10.90</price>
    <year>2018</year>
  </cd>
  <cd>
    <title>Falkon The Great Path</title>
    <artist>David Rosca (feat. Juraj Oravec)</artist>
    <country>CZ</country>
    <company>QtWebKit</company>
    <price>10.90</price>
    <year>2012</year>
  </cd>
  <cd>
    <title>Falkon Rebirth of RSS</title>
    <artist>Juraj Oravec</artist>
    <country>DE</country>
    <company>KDE</company>
    <price>9.90</price>
    <year>2021</year>
  </cd>
  <cd>
    <title>Falkon Preview RSS</title>
    <artist>Genghis</artist>
    <country>EG</country>
    <company>Cairo</company>
    <price>9.90</price>
    <year>2022</year>
  </cd>
</catalog>

XSL file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- xsl:output
method = 'html'
indent = 'yes'
omit-xml-decleration='no' /-->
<xsl:template match="/">
<html>
<head>
<title>transformed xml</title>
</head>
<body>
  <h2>My CD Collection</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th style="text-align:left">Title</th>
      <th style="text-align:left">Artist</th>
    </tr>
    <xsl:for-each select="catalog/cd">
    <tr>
      <td><xsl:value-of select="title"/></td>
      <td><xsl:value-of select="artist"/></td>
    </tr>
    </xsl:for-each>
  </table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Hello, I'm loading two files XML and XSL.
I'm attempting to put together an HTML page made by the combination of the two.
I guess I need to creat an element

and the append to it the result, but perhaps there's a neater solution.


Recently, more websites store data on JSON files and that data is rendered upon page load.

What my script does, is generating page Title (and also description note).

I'm attempting to get the name of a seller at https://www.aliexpress.com/item/4000087251384.html

        mediaUploader = document.evaluate('//h3[@class="store-name"]//a/text()', document, null, XPathResult.STRING_TYPE, null );

Yet, the following code is generated only on Event

    <div class="store-container" data-role="dsr">
        <h3 class="store-name" data-role="store-name"><a href="//www.aliexpress.com/store/614324?spm=a2g0o.detail.1000007.1.733865798XwyaA" target="_blank" data-spm-anchor-id="a2g0o.detail.1000007.1">The Supplier of High-end Glasses</a></h3>

        <div> <span data-role="positive-feedback"><i>97.4%</i> <span class="feedback-type">Positive feedback</span></span></div>
    </div>

    <div class="follow-container"><span class="text-btn follow" data-role="add-storelist" data-text-follow="Follow" data-text-following="Following">+ Follow</span>

        <p class="num-followers"><i>7122</i> Followers</p>
    </div>

Here's my script

// ==UserScript== 
// @name        Proper Title 
// @namespace   org.title.proper 
// @description Set sensible and functional page title and description 
// @grant       none
// @run-at      document-end
// @include     http://www.israelbar.org.il/*
// @include     https://addons.mozilla.org/*
// @include     https://github.com/*/*
// @exclude     https://github.com/*/*/blob/*
// @exclude     https://github.com/*/*/commit/*
// @exclude     https://github.com/*/*/issues/*
// @exclude     https://github.com/*/*/issues
// @exclude     https://github.com/*/*/notifications
// @exclude     https://github.com/*/*/orgs/*
// @exclude     https://github.com/*/*/projects
// @exclude     https://github.com/*/*/pull/*
// @exclude     https://github.com/*/*/pulls
// @exclude     https://github.com/*/*/pulse
// @exclude     https://github.com/*/*/search
// @exclude     https://github.com/*/*/wiki
// @exclude     https://github.com/*/*/wiki/*
// @exclude     https://github.com/notifications/*
// @exclude     https://github.com/sessions/*
// @exclude     https://gist.github.com/*/forked
// @exclude     https://gist.github.com/*/starred
// @include     https://gist.github.com/*/*
// @include     https://www.aliexpress.com/item/*
// @include     https://www.nevo.co.il/law_html/*
// @include     https://www.youtube.com/watch?v=*
// @include     https://openclipart.org/detail/*
// @include     https://sourceforge.net/projects/*
// @include     https://torrentz2.me/*
// @exclude     https://torrentz2.me/search*
// @version     1.0.0 
// ==/UserScript==
​
var mediaDescription,
    metaElements,
    mediaProducer,
    mediaTitle,
    mediaUploader,
    pageTitle;
​
metaElements = document.getElementsByTagName('meta');
mediaDescription = null;
​
switch (window.location.hostname)
​
{    
    case 'addons.mozilla.org':
        mediaTitle = document.evaluate('//h1/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaUploader = document.evaluate('//h1/span/a/text()', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = mediaTitle.stringValue + ' (by ' + mediaUploader.stringValue + ')';
        break;
​
    case 'www.aliexpress.com':
        mediaTitle = document.evaluate('//h1[@class="product-title-text"]/text()', document, null, XPathResult.STRING_TYPE, null );
        //mediaDescription = document.evaluate('h1[@class="product-title-text"]/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaUploader = document.evaluate('//h3[@class="store-name"]//a/text()', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = mediaTitle.stringValue + ' (by ' + mediaUploader.stringValue + ')';
        break;
​
    case 'github.com':
        //mediaTitle = document.evaluate('//strong[@itemprop="name"]//text()', document, null, XPathResult.STRING_TYPE, null );
        mediaTitle = document.evaluate('//strong[@itemprop="name"]/a/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaDescription = document.evaluate('normalize-space(//span[@itemprop="about"]//text())', document, null, XPathResult.STRING_TYPE, null );
        //mediaUploader = document.evaluate('//span[@itemprop="author"]//text()', document, null, XPathResult.STRING_TYPE, null );
        mediaUploader = document.evaluate('//a[@rel="author"]/text()', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = mediaTitle.stringValue + ' (by ' + mediaUploader.stringValue + ')';
        break;
​
    case 'gist.github.com':
        //mediaTitle = document.evaluate('//div[@itemprop="about"]/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaTitle = document.evaluate('//strong[@itemprop="name"]/a/text()', document, null, XPathResult.STRING_TYPE, null );
        //mediaUploader = document.evaluate('//span[@itemprop="author"]/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaUploader = document.evaluate('//span[@class="author"]/a/text()', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = mediaTitle.stringValue + ' (by ' + mediaUploader.stringValue + ')';
        break;
​
    case 'www.israelbar.org.il':
        switch (window.location.pathname)
​
        {
            case '/article_inner.asp':
                mediaTitle = document.evaluate('//div[@class="name"]/h1/text()', document, null, XPathResult.STRING_TYPE, null );
                mediaDescription = document.evaluate('//div[@class="article_container"]/div/text()', document, null, XPathResult.STRING_TYPE, null );
                pageTitle = mediaTitle.stringValue;
                break;
​
            case '/article.asp':
                mediaTitle = document.evaluate('//div[@class="s_title"]/text()', document, null, XPathResult.STRING_TYPE, null );
                pageTitle = mediaTitle.stringValue;
                break;
​
            case '/stage1_inner.asp':
                mediaTitle = document.evaluate('//div[@class="s_title"]//text()', document, null, XPathResult.STRING_TYPE, null );
                pageTitle = mediaTitle.stringValue;
                break;
​
            default:
                mediaTitle = document.evaluate('//div[@class="inner_title"]//span/text()', document, null, XPathResult.STRING_TYPE, null );
                pageTitle = mediaTitle.stringValue;
        }
        break;
        
    case 'www.nevo.co.il':
        mediaTitle = document.evaluate('//meta[@name="LAWNAME"]/@content', document, null, XPathResult.STRING_TYPE, null );
        mediaDescription = document.evaluate('//meta[@name="NOSE1"]/@content', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = mediaTitle.stringValue;
        break;
        
    case 'openclipart.org':
        mediaTitle = document.evaluate('//h2[@itemprop="name"]/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaDescription = document.evaluate('//dd[@itemprop="articleBody"]/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaUploader = document.evaluate('//span[@itemprop="name"]/text()', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = 'Clipart - ' + mediaTitle.stringValue + ' (by ' + mediaUploader.stringValue + ')';
        break;
        
    case 'sourceforge.net':
        //mediaTitle = document.evaluate('//h1[@itemprop="name"]/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaTitle = document.evaluate('//h1/text()', document, null, XPathResult.STRING_TYPE, null );
        //mediaDescription = document.evaluate('//p[@id="description"]/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaDescription = document.evaluate('normalize-space(//h3[@class="summary"]/text())', document, null, XPathResult.STRING_TYPE, null );
        //mediaUploader = document.evaluate('//p[@id="maintainers"]/a//text()', document, null, XPathResult.STRING_TYPE, null );
        mediaUploader = document.evaluate('//h3[@class="brought-by"]//a/text()', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = mediaTitle.stringValue + ' (by ' + mediaUploader.stringValue + ')';
        break;
        
    case 'torrentz2.me':
        mediaTitle = document.evaluate('//h2/span/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaAvailability = document.evaluate('//h2/text()', document, null, XPathResult.STRING_TYPE, null );
        //mediaDescription is not working
        mediaDescription = document.evaluate('//div[@class="download"]/div/span/@title', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = mediaTitle.stringValue + ' (available in ' + mediaAvailability.stringValue + ')';
        break;
        
    case 'www.youtube.com':
        mediaTitle = document.evaluate('//h1/text()', document, null, XPathResult.STRING_TYPE, null );
        mediaDescription = document.evaluate('//div[@id="content"]//text()', document, null, XPathResult.STRING_TYPE, null );
        mediaUploader = document.evaluate('//div[@id="owner-container"]//text()', document, null, XPathResult.STRING_TYPE, null );
        pageTitle = mediaTitle.stringValue + ' (by ' + mediaUploader.stringValue + ')';
        break;
}
​
document.title = pageTitle;
​
//loop through and find the element you want
for (var i = 0; i < metaElements.length; i++) {
  if (metaElements[i].getAttribute('name') == 'description') {
     if (mediaDescription == null) {
         //remove element
         metaElements[i].parentNode.removeChild(metaElements[i]);
     } else {
         //make necessary changes
         metaElements[i].setAttribute('content', mediaDescription.stringValue);
     }
     //stop loop upon action
     break;
  }
}

And here is an icon :-)

// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAABHNCSVQICAgIfAhkiAAAC+5JREFUeNrtnXtwVNUdx7/7yj6SbLJ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nonNH98+mMvP39S4iyryPdvnzpo6Jga8+GASf2o83wOTxcGagXzZ/GkwDFjQqRvCQ/fN5jU/v4AVw3yAy+qgKJrHKNpqc+LQVy24a3Eha/39y2eO+XydFvYH1eTyOG5V9IySTM//9kEr3G73/+PE2PnjP8bi/rer+jTcAe6Ik41a9Ph8y9J/OvZhAVuuJgUJiVJugEtKs7xJuxk4hmwUZfEYhdY2deKl7b5zKusMJjy1pRpuNxM0fcbFwD5o9exSVp7DvYqeOSubtTxwsRdpARKYrOoxmPCPj+p5S2usVf4/P25Ap24Iiyo0yM1KxtGaK/jkyHn09pnx7t5TSBzmJs9c0vmkP9hqADPsRigNwEeg1+t9Ts1ksmPhnG3Q9XjbZqnlOVBkJVGUFAVyGG3oPnbJA1gkEmL/kXUoLM7gVkXHx8fhpZfvYa3ra+yEuWMgdhvFk+Rn77Og979tLOt99LGFfuEGtOCrWr92N3Z9UMuO1DKVSMxPhUQpg0AoIHOKUC+Zw2SDuX0AQy29rPihpDQLVdVrIJaIxg54aNCKZQteR/t3/b4HCgQQK6UQySQEIJxsHS7YB6xgXG6/zdmqg4+goEgd8PhRAQPAQL8Fm5/ehz07T1FpR5Eq5uZh62srkatJGXW/oICvqnp/MzY9UcUKvEiRl1wuwYZnb8eq1bdCIAjuIjkDBgCr1YGmhk7U12lRX6dFU0MnzGY7lXoYJRGLUDgjA6Xl2Sgrz0HprGwkBXhgL2TApMknemSHAJMIMIkAkyZG/wMeCI07k6TzIAAAAABJRU5ErkJggg==






Getting the GM contributor for their mascot to do 3D may not be successful when the 2D svg support was requested and fizzled.

It does not have to be perfect, it may be just a monkey and the figure would be called Greasemonky. If you already know how the mascot of OpenUserJs roughly looks like, I suggest to make a 3D kart to feature in SuperTuxKart.


Last year, I have suggested in the SuperTuxKart forum to add a monkey figure and kart that would represent Greasemonkey and OpenUserJs.

Is there anyone here who designs 3D models with software such as Blender, and wants to provide a monkey figure with an OpenUserJs branded kart?