Skip to content

Instantly share code, notes, and snippets.

@johnhawkinson
Last active April 18, 2020 15:52
Show Gist options
  • Save johnhawkinson/3422116abd309f05281d26699a739038 to your computer and use it in GitHub Desktop.
Save johnhawkinson/3422116abd309f05281d26699a739038 to your computer and use it in GitHub Desktop.
ECF mobile bigbutton query
// ==UserScript==
// @name ECF mobile bigbutton query
// @version 1.0.8c
// @grant none
// @include https://ecf.*.uscourts.gov/cgi-bin/iquery.pl
// @include https://ecf.*.uscourts.gov/cgi-bin/*
// @run-at document-idle
// ==/UserScript==
// s = document.evaluate('//span[@id="case_number_area"]/ancestor::table[1]',document)
r = document.evaluate('//span[@id="case_number_area"]/ancestor::table[1]',document);
table = r && r.iterateNext();
function makeFieldClone(src, dst, setblur) {
src.oninput = function() {
dst.value = src.value.
replace(/\*/,':').
replace(/#/, 'cv');
var event = new InputEvent('paste', {
view: window,
bubbles: true,
cancelable: true
});
dst.dispatchEvent(event);
};
if (setblur) {
src.onblur=function() {
find = document.querySelector('#case_number_find_button_0');
find.dispatchEvent(new MouseEvent('click'));
};
}
}
if (table) {
row = table.insertRow(0);
row.innerHTML = ''+
'<td>REALLY BIG CASE NUMBER<br>* for :, # for cv<td>' +
'<input id="rbc" inputmode="tel" type="tel" style="width:400px; height: 50px; font-size: 18pt;">';
rbc = document.querySelector('#rbc');
cn = document.querySelector('#case_number_text_area_0');
makeFieldClone(rbc, cn, 'setblur');
}
// Now do it for mobile:
r = document.evaluate('//input[@id="caseOrNameSearch"]',document);
input = r && r.iterateNext();
rbcSubmit = document.querySelector('#RBCsubmit'); // idempotency
if (input && !rbcSubmit) {
div = input.parentNode;
ndiv = div.cloneNode('deep'); // strings are true
ninput = ndiv.children[0];
ninput.id += 'RBC';
ninput.name += 'RBC';
ninput.placeholder = 'Numeric: * for :, # for cv';
ninput.type = 'tel';
// per https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
// to be replaced by "enterkeyhint"
// citing to https://bugzilla.mozilla.org/show_bug.cgi?id=1490661
// which is down for maintenance as I write this. (\ldots{})
ninput.setAttribute('mozactionhint','Go');
// Now that we've added a 2nd input field, the form will no longer autosubmit without a submission input.
// annoying!
ndiv.insertAdjacentHTML('beforeend', '<input id="RBCsubmit" type="submit" value="Submit" style="display: none">');
div.parentNode.prepend(ndiv);
// turns out we don't have any of that fancy JS validation in this version
makeFieldClone(ninput, input, false);
// And indeed, we need to force an early submittal
ninput.onblur = function() {
// console.log('preblur');
this.form.submit();
// console.log('postblur');
};
}
window.setTimeout(function() {
y = document.querySelector('#_yuiResizeMonitor')
console.log(y.style.cssText);
// position: absolute; visibility: visible; width: 10em; height: 10em; top: -164px; left: -164px; border-width: 0px;
// if (y) {
// y.style.cssText = ""; // }
y.style.cssText = 'position: fixed; visibility: visible; width: 2em; height: 10em; top: -0; left: -0; border-width: 0px;';
y2 = document.querySelector('#topmenu');
old = y2.style.position; // static
y2.style.position="";
}, 0);
var i=document.getElementById("list_of_parties_and_counsel");
if (i) {
i.checked = false;
var n = i.nextElementSibling;
n.insertAdjacentHTML('beforebegin', " <i>(Cleared by script)</i>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment