Jump to content

User:Smallman12q/test2.user.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// ==UserScript==
// @name           Red Link Recovery
// @namespace      http://www.google.com
// @description    A test
// @include        https://secure.wikimedia.org/wikipedia/en/wiki/User:Smallman12q/test
// @include        http://en.wikipedia.org/wiki/User:Smallman12q/test
// @include        http://www.google.com/
// ==/UserScript==
//http://wiki.github.com/Martii/greasemonkey/unsafewindow
function myScript() 
{
	var answer = confirm  ("Would you like to load the Red Link Recovery Tool now?\nPres 'OK' to load\nPress 'Cancel' to not load")
	if (answer)
	{
		alert ("I'll load it now.");
		document.body.innerHTML = '';//clear the page
                alert("going to write");
                try
                {
    var oNewDoc = document.open("text/html", "replace");
    var sMarkup = "<html><head><title>New Document</title></head><body>Hello, world</body></html>";
    oNewDoc.writeln("<html>");
oNewDoc.writeln("<head>");
oNewDoc.writeln("<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\">");
oNewDoc.writeln("<title>Title 1<\/title>");
oNewDoc.writeln("<\/head>");
oNewDoc.writeln("<frameset rows=\"177,*\">");
oNewDoc.writeln("	<frame name=\"banner_frame\" scrolling=\"no\" noresize=\"noresize\" src=\"http:\/\/en.wikipedia.org\/w\/index.php?action=raw&ctype=text\/javascript&title=User:Smallman12q\/htmltest\">");
oNewDoc.writeln("	<frameset cols=\"50%,50%\">");
oNewDoc.writeln("		<frame name=\"refer_frame\" src=\"http:\/\/en.wikipedia.org\/wiki\/HTTP_referrer\" scrolling=\"auto\">");
oNewDoc.writeln("		<frame name=\"target_frame\" src=\"http:\/\/en.wikipedia.org\/wiki\/Target_shooting\" scrolling=\"auto\">");
oNewDoc.writeln("	<\/frameset>");
oNewDoc.writeln("	<noframes>");
oNewDoc.writeln("	<body>");
oNewDoc.writeln("");
oNewDoc.writeln("	<p>This page uses frames, but your browser doesn&#39;t support them.<\/p>");
oNewDoc.writeln("");
oNewDoc.writeln("	<\/body>");
oNewDoc.writeln("	<\/noframes>");
oNewDoc.writeln("<\/frameset>");
oNewDoc.writeln("");
oNewDoc.writeln("<\/html>");
oNewDoc.writeln("");
    oNewDoc.close();
                 }
                catch(err)
                {
                    alert("Error:" + err.description);
                 }
		
                alert("finished write");
	}
	//else
	//	alert ("Darn. Well, keep trying then.")
  //for (var x in document) {
    /* some code with x */
  //}
  /* some code */
}

function writein()
{
    alert("writing");
    var oNewDoc = document.open("text/html", "replace");
    var sMarkup = "<html><head><title>New Document</title></head><body>Hello, world</body></html>";
    oNewDoc.writeln("<html>");
oNewDoc.writeln("<head>");
oNewDoc.writeln("<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\">");
oNewDoc.writeln("<title>Title 1<\/title>");
oNewDoc.writeln("<\/head>");
oNewDoc.writeln("<frameset rows=\"177,*\">");
oNewDoc.writeln("	<frame name=\"banner_frame\" scrolling=\"no\" noresize=\"noresize\" src=\"Test_table.html\">");
oNewDoc.writeln("	<frameset cols=\"50%,50%\">");
oNewDoc.writeln("		<frame name=\"refer_frame\" src=\"http:\/\/en.wikipedia.org\/wiki\/HTTP_referrer\" scrolling=\"auto\">");
oNewDoc.writeln("		<frame name=\"target_frame\" src=\"http:\/\/en.wikipedia.org\/wiki\/Target_shooting\" scrolling=\"auto\">");
oNewDoc.writeln("	<\/frameset>");
oNewDoc.writeln("	<noframes>");
oNewDoc.writeln("	<body>");
oNewDoc.writeln("");
oNewDoc.writeln("	<p>This page uses frames, but your browser doesn&#39;t support them.<\/p>");
oNewDoc.writeln("");
oNewDoc.writeln("	<\/body>");
oNewDoc.writeln("	<\/noframes>");
oNewDoc.writeln("<\/frameset>");
oNewDoc.writeln("");
oNewDoc.writeln("<\/html>");
oNewDoc.writeln("");
    oNewDoc.close();
alert("written");

}

/*
  Attaches script into page body and executes it via an anonymous function call.
    NOTES:
      Script can therefore reference variables on the page,
      but likewise cannot use Greasemonkey API methods
	  
*/
var script = document.createElement("script");
script.type = "application/javascript";
script.textContent = "(" + myScript + ")();";

document.body.appendChild(script);