讨论 » 创建请求

Run a js script automatically on a website?

§
发表于:2016-04-07

Run a js script automatically on a website?

So there's a website called Dubtrack, and a plugin for it called MikuPlugin. What you do is add a js shortcut to your bookmarks and run it every time you visit the website.

However I would like to run it automatically whenever I join it. The js shortcut you add to bookmarks is as follows:

javascript:(function(){$.getScript('https://dl.dropboxusercontent.com/s/jxdivcxohiwc511/Main.js');}());

So basically, how do I run this automatically on dubtrack.fm?

§
发表于:2016-04-08
编辑于:2016-04-08

Hi there,
- to run user scripts on Firefox you need to have the Greasemonkey addon installed [the script-manager]
- a script is a plain textfile with any name and the extension .user.js

- a user-script contains two essential parts:
-- 1 -- the script header (needed to manage the script/s)
-- 2 -- the script itself that shall be processed

- simple installation: drag & drop a anyname.user.js onto the open firefox and greasemonkey will ask if it shall be installed. Confirm and you're done.

@include assigns the target-page where the script shall run and @require can contain target-files which are loaded when the script is invoked.

NOTE: any loading of unknown external files is of serious concern and therefore omitted from scripts on GreasyFork. Only approved files are allowed.

Now this external file loading is exactly the only command your bookmarlet executes and you should be aware about potential dangers that can always come with doing alike.
However, I've checked that Main.js - it looks clean and would make a good user-script on its own.

As for you request I've made a template-script for you. Make it a text-file like described above, adjust its contains to your needs, install and use at your own risk :wink:

häppy chätting ~ Vivre

// ==UserScript==
// @name           	call MikuPlugin
// @namespace		Ketchup901
// @description    	load external Main.js
// @author		friendly guy
// @version		0.1 - 2016-04-07
// @include        	*dubtrack.fm/*
// @require		https://... insert your link here
// @run-at document-end
// ==/UserScript==

// no script needed

// in case @require doesn't workout, try by uncommenting the following line:

//  (function(){$.getScript('https:// ... insert your link here');}())

发表回复

登录以发表回复。