javascript - Tampermonkey - add page using non-existing URL -


i'm creating userscript adds new functions website. website has many users, doesn't have feature search users.
i want create such function. that, have created button in existing search page other search purposes. when click button, need script search input on google , fetch urls , show results in piece of html code on non-existing page.

can fake url userscript, uses show html?

if not, can replace html within page?

code isn't interesting. adds button link , selects when on non-existing page.

code:

if (document.url == "http://www.bierdopje.com/search" || document.url == "http://www.bierdopje.com/search/" || window.location.href.indexof("search/shows") > -1 || window.location.href.indexof("search/episodes") > -1 || window.location.href.indexof("search/forum") > -1) { var users = document.createelement('li'); users.setattribute('class', 'strong'); var usersnode = document.createtextnode("gebruikers"); var userslink = document.createelement('a'); userslink.setattribute('href', 'http://www.bierdopje.com/search/users/');  document.getelementbyid("submenu").childnodes[1].appendchild(users).appendchild(userslink).appendchild(usersnode);  if (window.location.href.indexof("search/users/") > -1) {     userslink.setattribute('href', './');     userslink.setattribute('class', 'selected'); } } 

sorry answering own question, brock adams said: may have been localized.
solution fake url replace 404 not found content.

if there's container header , paragraph, find container making variable, , replace variable:

// find container var example = document.getelementbyid('container').childnodes[0];  // set new container var newcontainer = document.createelement('div'); newcontainer.setattribute('id', 'ncontainer');  // replace existing container new 1 example.parentnode.replacechild(replacement, example);  // write content new container document.getelementbyid('ncontainer').innerhtml ='<p>this not 404 anymore</p>'; 

there lot more , shorter ways accomplish this, can found google (javascript replace).

replace complete page, use

document.write() 


finish page, can set title following:

document.title = "website title"; 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -