RenderedNonsense RenderedNonsense - 1 year ago 64
HTML Question

Remove text on web page - following a String ">>" until next break

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.


Answer Source

  c[b].innerHTML = a.innerHTML.replace(/>.*/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?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download