The Secret Diary of Han, Aged 0x29

twitter.com/h4n

Archive for October 2005

Auto filter submit for sourceforge

In the new sourceforge, after entering filter conditions, you have to scroll all the way down to the bottom of the artifact list to press the ridiculously placed “Apply Filter” button.Here is Greasemonkey script that auto submits a filter if any of the conditions change, without having to press that button.

// Autosubmit Sourceforge filter
// 2005-10-08
// Han Kessels
// ——————————————————————–
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to “Install User Script”.
// Accept the default configuration and install.
//
// ==UserScript==
// @name Autosubmit Sourceforge Filter
// @namespace http://mywebsite.com/myscripts
// @description Submits a filter after making a change to one of the filter
// input fields in sourceforge. Avoids having to scroll down the page and hit
// the Apply Filter button
// @include https://sf.decafe-ntt.com/sf/*
// ==/UserScript==

var forms = document.getElementsByTagName(“form”);
if (forms.length == 0)
return;
var form = forms[0];

var inputs = document.getElementsByTagName(“INPUT”);
var sfsubmit;
for (var i=0; i < inputs.length; i++) { if (inputs[i].name == "sfsubmit") sfsubmit = inputs[i]; } if (sfsubmit == undefined) return; var filter = document.getElementById("filter"); if (filter == undefined) return; var els = document.evaluate( "//*[@class='InputField' or @class='FilterInput']", filter, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < els.snapshotLength; i++) { var el = els.snapshotItem(i); el.addEventListener('change', function(event) { form.setAttribute("action", location.pathname); sfsubmit.setAttribute("value","_filterApply"); form.submit(); event.stopPropagation(); event.preventDefault(); }, true); }[/sourcecode]

Written by Han

October 7, 2005 at 19:36

Posted in Uncategorized