Last active
March 4, 2020 02:27
-
-
Save roylez/8633e9b59406030f9c297b3e54e97e7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name SFComment | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Some SF comment window hacks | |
// @author roylez | |
// @include https://canonical*.visual.force.com/servlet/servlet.Integration* | |
// @license MIT | |
// @require https://code.jquery.com/jquery-2.2.4.min.js | |
// @updateURL https://gist.github.com/8633e9b59406030f9c297b3e54e97e7b/raw/SFComment.user.js | |
// @downloadURL https://gist.github.com/8633e9b59406030f9c297b3e54e97e7b/raw/SFComment.user.js | |
// @run-at document-idle | |
// ==/UserScript== | |
function inject_css() { | |
$("head").append('<meta name="viewport" content="width=device-width, initial-scale=1">') | |
$("head").append('<link ' + 'href="//unpkg.com/tachyons@4/css/tachyons.min.css" ' + 'rel="stylesheet" type="text/css">') | |
} | |
function update_timecard(window) { | |
var w; | |
if (typeof unsafeWindow != undefined) { | |
w = unsafeWindow | |
} else { | |
w = window; | |
} | |
var timecard = $('input[name="vfpage:caseForm:caseBlock:CommentsSection:TimeSpentRequired:timeSpent"]') | |
function listener(event){ | |
if ( event.data.timecard && !timecard.val() ) { timecard.val( event.data.timecard ) } | |
} | |
w.addEventListener("message", listener,false) | |
timecard.on("focusin", function() { w.parent.postMessage("getTime","*") }) | |
} | |
function default_inputs() { | |
let status = $('select[name="vfpage:caseForm:caseBlock:CommentsSection:StatusRequired:caseStatus"]') | |
status.val("Waiting on Customer") | |
let comment = $('textarea[name="vfpage:caseForm:caseBlock:CommentsSection:CaseCommentRequired:caseComment"]') | |
comment.addClass('code black bg-washed-green db border-box hover-black br2 b--black-20 w-90') | |
comment.val("Hello,\n\n") | |
} | |
inject_css() | |
update_timecard(window) | |
default_inputs() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment