Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Função BETA
- * Fazer substituição de textos, ignorando os caracteres HTML!
- */
- function replaceHTML(text, textReplace){
- var node = document.body.textContent;
- var n = node.search(text) ;
- var c = 0;
- var i = -1;
- var z = 0;
- var f = 0;
- if(n != -1) {
- var html = document.body.innerHTML;
- var arr = html.split(' ');
- for(var x = 0; x < arr.length; x++) {
- if(!isset(arr[x])) continue;
- z += (x + arr[x].length);
- idx = arr[x].replace(/<[^>]+>/ig,'');
- if(idx.length == 0) continue;
- t = true;
- b = z;
- for( ; b > -1; b--) {
- if(html[b] == '<') {
- t = false;
- }
- if(html[b] == '>') {
- break;
- }
- }
- for(b = z; b < html.length; b++) {
- if(html[b] == '>') break;
- z ++;
- }
- if(idx.search(text.split(' ')[c]) != -1) {
- if( c == 0 ) i = z - (x + arr[x].length);
- c ++;
- if( c == text.split(' ').length ) {
- f = z ;
- break;
- }
- }
- else
- {
- i = -1;
- c = 0;
- }
- }
- if(i != -1) {
- html = document.body.innerHTML;
- output = "";
- output = html.substr(0, i) + textReplace + html.substr(f);
- document.body.innerHTML = (output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement