I'm using NinjaKit in Safari (Same as Greasemonkey). The codes are like this
// ==UserScript==
// @name demo
// @namespace http://dailymed.nlm.nih.gov/
// @include http://dailymed.nlm.nih.gov/dailymed/*
// @require http://code.jquery.com/jquery-1.11.0.min.js
// @require http://johannburkard.de/resources/Johann/jquery.highlight-4.closure.js
// ==/UserScript==
$(document).ready(function () {
document.title = 'Hello!' + document.title;
alert("ZaiJian");
$("body p").highlight(["a"]);
});
When I visit this page, the alert
can be displayed well, but the .highlight
function which depends on jQuery.highlight
and jQuery
doesn't work. It says:
TypeError: 'undefined' is not a function (evaluating 'c.toUpperCase()')
And I find it quite hard to debug this.. Does anyone have ideas about it?
I believe that NinjaKit currently doesn't do @require. Here's an example I made, that works in Firefox/GreaseMonkey and not in Safari/Ninjakit:
// ==UserScript==
// @name DEBUG
// @include http://localhost/Library.html
// @require file:///Users/#######/Sites/hello_world.js
// @require http://localhost/~#######/hello_world.js // EITHER WAY
// ==/UserScript==
alert('activated');
hello_world();
# hello_world.js
function hello_world(){
alert('Hello World!');
}
Either as a "remote" address or a local file, it worked fine in GreaseMonkey and failed in Safari. It's hard to get the ins-and-outs of NinjaKit currently, in my experience.