Req: binsearch.info - remember default search age
|
|
binsearch.info has changed something to where now when you try to change the default search age that firefox won't keep your setting...So does anyone have any ideas as to how a script could be made that will make firefox remember the setting?? |
|
|
gm_setvalue and gm_getvalue -Joel |
|
|
Joel,
|
|
|
It strikes me that the simplest way to do this would be simply to manipulate the url; changing the // ==UserScript==
// @name foo
// @include http://binsearch.info/?q=*
// ==/UserScript==
if !(/&adv_age=\d+/.test(document.location.href)) {
document.location.replace(document.location.href + "&adv_age=" + GM_GetValue("search age", 7))
} else if (document.location.href.match(/&adv_age=(\d+)/)[1] != GM_GetValue("search age", 7)) {
document.location.replace(document.location.href.replace(/&adv_age=(\d+)/, "&adv_age=" + GM_GetValue("search age", 7)))
}
GM_registerMenuCommand(
"Set search age...",
function() {
age = prompt("Enter search age in days:",GM_getValue("search age", 7));
if (age!=null && age!="") {
GM_setValue("search age", parseInt(age));
}
})This is completely untested and written on the fly, but I think it should work.
|
|
|
Thanks for your efforts Znerp,
|
|
|
No results at all sounds strange because my code shouldn't remove anything. I installed this script and so I know it works fine for me now and I've ironed out the minor bugs. Try this; // ==UserScript==
// @name foo
// @include http://binsearch.info/?q=*
// ==/UserScript==
if (!(/&adv_age=\d+/.test(document.location.href))) {
document.location.replace(document.location.href + "&adv_age=" + GM_getValue("search age", 7))
} else if (document.location.href.match(/&adv_age=(\d+)/)[1] != GM_getValue("search age", 7)) {
document.location.replace(document.location.href.replace(/&adv_age=(\d+)/, "&adv_age=" + GM_getValue("search age", 7)))
}
GM_registerMenuCommand(
"Set search age...",
function() {
age = prompt("Enter search age in days:",GM_getValue("search age", 7));
if (age!=null && age!="") {
GM_setValue("search age", parseInt(age));
}
})
|
|
|
I still have no results with this...just how do you get it to work for you....and does it work still if you close firefox and then go back to the site (binsearch.info) later...I just want firefox to remember my default search age of 70 days.
|
|
|
Ok ... I'll go through this step by step with you. When performing a search on binsearch.info, the search age is specified in the url by The code I wrote performs a simple if-else to check firstly if you're on a search page and Just for good measure and useability, I then added a menu command to allow you to set the number of days (right click on the monkey when on a results page then "User Script Commands.." then "Set search age..") If this still isn't working for you, then could you please paste the url of a test search and I'll see if I can see what went wrong. Sorry I hadn't explained all of this before, I'd assumed that since you were a scriptwright you might be able to work out what my code is doing. |
|
|
ok...I got it now!!
|
|
|
http://userscripts.org/scripts/show/24743 I hope I explained this well enough to all other users! |
