4

I made this to filter results in a case-sensitive manner on Google. Where the issue arises is in the fact that each string is not on its own line despite my inclusion of "\n." (In the picture, periods are absent because I executed the replace function. However, the new line does not surface.)

(function () {
    if (!console) {
        console = {};
    }
    var old = console.log;
    var logger = document.getElementsByClassName('g kno-kp mnr-c g-blk')[0];
    console.log = function (message) {
        if (typeof message == 'object') {
            logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(message) : String(message)) + '<br />';
        } else {
            logger.innerHTML += message + '<br />';
        }
    }
})();

var p=/Opportunity cost(.*?)\./gm;console.log(document.body.innerText.match(p))

var str = document.getElementsByClassName('g kno-kp mnr-c g-blk')[0];
var inner = str.innerHTML;
var res = inner.replace(/\./gi, "\n");
str.innerHTML = res;

enter image description here

Johnny
  • 125
  • 9

0 Answers0