Answer the question
In order to leave comments, you need to log in
How to remove all META tags and other information from the page received by the XMLHttpRequest() method?
Hello, dear masters and craftswomen, I ran into a very interesting problem, when parsing a page through XMLHttpRequest(), all information about the page remains, this is logical, but the question is how to remove it?
Below is the code and screenshot of the problem:
document.addEventListener('DOMContentLoaded', function LoadComments() {
(function LoadComments() {
var CommentsSite = new XMLHttpRequest();
CommentsSite.open("GET","/com.html="+location.pathname+"", true);
CommentsSite.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var g = new DOMParser().parseFromString(this.responseText, "text/html");
var g = CommentsSite.responseText;
var repcen = 'post"><span>';
g = g.replace('post"><div>', repcen);
repcen = '';
g = g.replace('<div class="top">Комментарии</div>', repcen);
g = g.replace('">далее</a>', repcen);
g = g.replace('<br /><a href="/">Назад</a><br /><div class="btm"><a href="'+location.origin+'">На главную</a></div>', repcen);
g = g.replace('<div class="ddd"><a href="/">Вернуться назад</a></div>', repcen);
g = g.replace('<div class="user_ddd"><a href="/">Вернуться назад</a><a href="/user/lb.html">Личный кабинет</a></div>', repcen);
repcen = '<body><div class="comments__block">';
g = g.replace('<body><div>', repcen);
repcen = '<span class="common">';
g = g.replace(/<div class="common">/g, repcen);
repcen = 'span><br ';
g = g.replace(/div><br /g, repcen);
repcen = '<div class="log_reg_block" style="display:none;">';
g = g.replace(/<div class="log_reg_block">/g, repcen);
repcen = '<form action="/comments';
g = g.replace('<form action="comments', repcen);
repcen = '<a href="/comments';
g = g.replace('<a href="comments', repcen);
g = g.replace(/<a href="ank.html(.*?)">(.*?)</g, '<a href="/ank.html$1">$2<');
document.getElementById("s_cos").innerHTML = g;
}
}
CommentsSite.send(null);
})()}, false);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question