-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCase_link_interceptor.user.js
More file actions
39 lines (33 loc) · 1.29 KB
/
Case_link_interceptor.user.js
File metadata and controls
39 lines (33 loc) · 1.29 KB
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
34
35
36
37
38
39
// ==UserScript==
// @name Case link interceptor
// @namespace http://csutherl.github.io/
// @version 0.4
// @description Script to intercept and change case link clicks to use salesforce instead of the portal
// @author coty
// @match https://access.redhat.com/*
// @match https://bugzilla.redhat.com/*
// @exclude https://access.redhat.com/support/cases/internal/case/*
// @grant none
// @updateURL https://github.com/csutherl/random-userscripts/raw/master/Case_link_interceptor.user.js
// ==/UserScript==
/* jshint -W097 */
'use strict';
function interceptClickEvent(e) {
var href;
var target = e.target || e.srcElement;
if (target.tagName === 'A') {
href = target.getAttribute('href');
if (href.match('/support/cases/')) {
var casenum = href.match('[0-9]+');
//tell the browser not to respond to the link click
e.preventDefault();
window.open("https://c.na7.visual.force.com/apex/Case_View?sbstr=" + casenum);
}
}
}
// listen for link click events at the document level
if (document.addEventListener) {
document.addEventListener('click', interceptClickEvent);
} else if (document.attachEvent) {
document.attachEvent('onclick', interceptClickEvent);
}