-
Notifications
You must be signed in to change notification settings - Fork 1
/
trackermonkey.js
33 lines (28 loc) · 943 Bytes
/
trackermonkey.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// ==UserScript==
// @name Tracker Monkey
// @namespace moodle
// @version 0.1
// @description Redirect MDL searches to Tracker
// @author Mick Hawkins
// @source https://github.com/mickhawkins/trackermonkey
// @include /^https:\/\/(www\.)?duckduckgo\.com\/\?q=MDL*/
// @include /^https:\/\/(www\.)?google\.com(\.[a-z]{2,})?\/(search)?\?(.*&)?q=MDL*/
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.stop();
var url = window.location.href;
var patt = /MDL([^&]*)(&.*)*/i;
var result = patt.exec(url);
var redirect = 'https://tracker.moodle.org/';
if (result[1] != undefined) {
var search = result[1];
if (search.charAt(0) == '-') {
redirect += 'browse/MDL' + result[1];
} else if (search.indexOf('me') < 2) {
redirect += 'issues/?filter=-1';
}
}
window.location = redirect;
})();