Skip to content

Instantly share code, notes, and snippets.

@arantius
Created January 10, 2013 15:14
Show Gist options
  • Save arantius/4502790 to your computer and use it in GitHub Desktop.
Save arantius/4502790 to your computer and use it in GitHub Desktop.
Test for Greasemonkey issue 1673
<?
if ($_POST) {
// Save the POSTed name in a cookie.
setcookie('script_name', $_POST['script_name']);
// Redirect to the user script installation handler.
//xxx header("Location: {$_SERVER['REQUEST_URI']}?.user.js");
?>
<meta http-equiv="refresh" content="0;<?=$_SERVER['REQUEST_URI']?>?.user.js">
<?
} else if (false !== strpos($_SERVER['REQUEST_URI'], '.user.js')) {
header('Content-Type: text/javascript');
?>
// ==UserScript==
// @name <?=$_COOKIE['script_name']?>
// ==/UserScript==
console.log('test script dynamically generated from POSTed data');
<?
} else {
?>
<!DOCTYPE html>
<html>
<head>
<title>Greasemonkey POST + install test</title>
<body>
<form method='post'>
Script name: <input type='text' name='script_name'>
<input type='submit'>
<?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment