RenderedNonsense RenderedNonsense - 23 days ago 6x
HTML Question

Remove text on web page - following a String ">" until end of span

I interact with a web page at work that overloads me with redundant information of the form:

Important text
Other important text
>> Not important 1
>> Not important 2
>> Not important 3
Other important text

I would love some javascript code that I can run in Tampermonkey that deletes all of the text in all spans starting from the first occurrence of
and ending at the end of the given span tag

Pseudo-code example:

var allSpanTags = document.getElementsByTagName('span');

for(var thisSpanTag in allSpanTags){
thisSpanTag.innerHTML.deleteStringBetween(index_of_first_">"_in_given_spans_inner_HTML , index_of_end_of_innerHTML_of_this_span_tag);

The intricacies of the web beast are currently befuddling me on this project in JavaScript (not my native language). I'm also uncertain that I am even approaching the issue in the most effective manner.


Edit: I made my code apply specifically to spans with a certain className so that it would stop breaking other stuff on the webpage.

var allSpans = document.getElementsByTagName("span");
for(var i = 0; i < allSpans.length; i++) {
if (allSpans[i].className.indexOf("textblock") > -1) {
allSpans[i].innerHTML = allSpans[i].innerHTML.replace(/&gt;.*/g, '');


    a => a.innerHTML = a.innerHTML.replace(/&gt;.*/g,'')
<span>Please delete after the > sign here!</span><br>
<span>Also, delete the sign > here!</span><br>
<span>Don't > forget > me!</span>

How about this solution?