wnewhous,
I would not use the text of the link as a way of selecting content if there is another way to do so. The text varies based on someone's language. As long as everyone was using the same language for Canvas, it should be okay.
In the case of the help menu, I would base it off the href for the link. The bonus is that you can do that with a CSS selector, while you cannot for text. I think I've seen Robert do something with xpath that can do that. There's also a note that xpath support varies widely by browser and while Firefox supports it, there's no plan to improve it. Regardless, you're back to the first issue that the text may vary.
If the text you're looking for is set by you and you don't support internationalization, then it may also be okay to select, but the href route is still faster.
Let's say that my help dialog looks like this, where the last entry is a link to office.com

This CSS selector will find that anchor element for the Student Email.
#help_tray li a[href="https://office.com"]
Now what I need to do is find the parent list item element.
The underlying HTML for that entry in the DOM looks like this and this is inside of a unordered list element which is inside a div with an id of help_tray.
<li class="fOyUs_bGBk dxCCp_bGBk dxCCp_fLbg dxCCp_ycrn dxCCp_cfzP dxCCp_bCcs">
<span direction="row" wrap="no-wrap" class="fOyUs_bGBk fOyUs_desw bDzpk_bGBk bDzpk_oDLF bDzpk_fZWR bDzpk_qOas">
<span class="fOyUs_bGBk dJCgj_bGBk" style="min-width: 100%; flex-basis: 100%;">
<a target="_blank" rel="noopener" href="https://office.com" role="button" tabindex="0" class="fOyUs_bGBk fbyHH_bGBk fbyHH_bSMN">Student Email</a>
<div class="cjUyb_bGBk cjUyb_doqw cjUyb_eQnG">Check your student email in Office 365's Outlook.</div>
</span>
<span class="fOyUs_bGBk dJCgj_bGBk"></span>
</span>
</li>
Those classes are not static between builds, which used to be every three weeks, then went to once a month, and now with the COVID-19 thing might be changing every week. In other words, most definitely do not rely on them.
Now, let's say that you want to insert your own link first and you want it to look like all the others. The first thing to do is to find a link that is styled the way that you want you link to work. That probably means not having "new" or "featured", but just a regular link. Let's say the "report a problem" link. The href for it is #create_link.
Here is something that I threw together very quickly. It should only be called after you have verified that the help_tray div exists via a mutation observer and possibly even that it's displayed to keep Canvas from overwriting your changes -- you would have to play around with that to make sure it's right.
(function() {
'use strict';
const helptray = document.getElementById('help_tray');
const helplinks = helptray.querySelector('ul');
const firstlink = helptray.querySelector('ul>li');
const problemlink = helptray.querySelector('a[href="#create_ticket"]');
const problem = problemlink.closest('li');
const node = problem.cloneNode(true);
const nodelink = node.querySelector('a[href="#create_ticket"]');
const description = node.querySelector('a[href="#create_ticket"] + div');
nodelink.href = 'https://google.com';
nodelink.textContent = 'Google It';
description.textContent = 'If you cannot figure it out, Google it.';
helplinks.insertBefore(node, firstlink);
})();
What this does is to find the Report a Problem link based off the href rather than the text so that it isn't dependent upon the language selected by the user.
Then it clones that node using a deep clone. We now have an identical copy of that node.
We're going to change the href and text of the link and the text of the div that immediately follows the link. This holds the description.
In my example, I'm giving students the best help I can -- telling them to Google It.
After that is changed, it inserts the node before the top help link. If there's ever more than one list in the help_tray, you could use problemlink.closest('ul') to make sure you get the right one. Older browsers may need a polyfill for closest(), but those browsers aren't supported by Canvas anyway.
When I run this, my help menu now looks like this.

If I knew, and could guarantee, what the first link was going to be, I could have just used it to clone and saved some steps, but I don't know when Canvas is going to put something at the top of the help links.
I apologize for the poor formatting on the code, I was typing it into the browser's console and it was acting really slow on me. I guess I had too many Chrome windows open (or maybe just the wrong ones). I need to reboot my computer but I didn't want to do it while writing your message.
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.