its my first posting so be gentile.
I'm looking to get a Greasemonkey script coded to take certain snippets of data, in this case the Agent ID and Ticket Number and export them to Excel.
I've hacked together something which basically plops the details into outlook to email it onwards to someone but Im just looking to 'correlate' on a webpage, however right now I have limited resources in the office and no access to create a MySQL DB internally (though this should be done for me soon) and likely make things much easier :)
This is the code I have from the existing script which also outputs the results to a page that doesn't exist anymore (I get the feeling the previous guy was thinking the same as I was)
// ==UserScript==
// @name Easy Feedback
// @namespace http://blah
// @description Easy feedback buttons
// @include https://blah.example.com/custdetails-new.html*
// @include https://blah.example.com/ticket_show.html*
// ==/UserScript==
// Inject jQuery into the host
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
// Burst out of its stomach
function main() {
// Get the current URL
var sAgent = "";
var sTicket = "";
// Get current ticket (if possible)
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
if (vars["ticket_id"]) {
sTicket = vars["ticket_id"];
}
// Add feedback buttons
$("td:contains('Company staff')")
.not(":contains('Raised:')")
.not(":contains('by:')")
.each(function() {
var tmpTicket = "";
if (sTicket == "") {
var tmp = $(this).closest(":contains('Ticket:')").children(0).children(0).children(0).children(0).children(0).children(0).text();
var matched = tmp.match(/Ticket:[\s]+(.)+/);
tmpTicket = matched[0].substr(8);
} else {
tmpTicket = sTicket;
}
tmp = ($(this).text()).match(/.+\(/);
sAgent = tmp[0].substr(0, tmp[0].length - 1);
$(this).append('<br /><br /><a href="mailto:mail@example.com?subject=Feedback on ' + sAgent + ' (' + tmpTicket + ')&body=Agent: ' + sAgent + '%0ATicket: ' + tmpTicket + '%0A%0A%0ADetails:">Feedback</a>').children(0).click(function() {
$(this).parent().parent().fadeOut(200);
Record the click for Monitoring
var tmpId = Math.floor(Math.random()*100);
$('<iframe name="feedback' + tmpId + '" id="feedback' + tmpId + '" src="WEBSITE/Feedback/record.html?ticket=' + tmpTicket + '&agent=' + sAgent + '" style="display:none;" />').load(function() {
$(this).remove();
}).appendTo('body');
$(this).parent().parent().fadeIn(200);
});;
});
}
// Plant that seed
addJQuery(main);
So... yeah any advice would be greatly appreciated.
I will throw my hands up and admit I haven't coded for a while but what I have done while here is fix broken code to make things work so my coding is the more 'hack and slash' with no specialization... :/
I get the feeling that he pointed this to a DB somewhere and then displayed the results on the html page though I cant be sure as this was created long before my time with the company