Recent posts by Descriptor

Subscribe to Recent posts by Descriptor 758 posts found

Mar 29, 2008
Descriptor 757 posts

Topic: Script development / Userscripts Code Block Fix


dob wrote:
I edited my post, because it was killed by the formatting. It just closes tags that I intentionally leave open, even if they're htmlentities.

Ahh, I see, but put them in <code> tags and it should work. test <input>, but I agree it should at least ignore tags that aren't accepted as markup code. Use &amp;lt; for entities &lt;

 
Mar 29, 2008
Descriptor 757 posts

Topic: Script development / Problem Populating form

Well, I just tried it as a "bookmarklet", but yes, it changes it to March.

Also, znerp's code will get the correct form, based on the action attribute, in case some other form is dynamically added before that one.

 
Mar 28, 2008
Descriptor 757 posts

Topic: Script development / Problem Populating form

Well, for the select lists you have to do it different, like
document.forms[1].elements.namedItem('birthmonth').selectedIndex = 2;

 
Mar 28, 2008
Descriptor 757 posts

Topic: Script development / Problem Populating form

@dob
That will match document.forms[0].elements.namedItem('email') first.

Just try typing in Location javascript:alert(document.forms[2].action) or javascript:alert(document.forms[2].elements[0].value) to make sure you have the correct form.
No alert probably means no form by that number.

Also you can use
var Form = document.getElementsByName("unique_name_or_id")[0].form
or I'd use XPath.

 
Mar 28, 2008
Descriptor 757 posts

Topic: Script development / possible dumb xpath question

And you want the stringValue property of the XPathResult.STRING_TYPE. I noticed an example here:
http://developer.mozilla.org/en/docs/Code_snipp...

 
Mar 28, 2008
Descriptor 757 posts

Topic: Script development / Userscripts Code Block Fix

@dob
turn off Greasemonkey and reload the page, there's nothing wrong with the post - my syntax highlighter is doing the same thing.

@Aquilax
You can use a function in replace, so I think there's a shorter way to do that (no time, but intriguing).

 
Mar 28, 2008
Descriptor 757 posts

Topic: Script development / split

I figured it out, I had it backwards...
"1234567890".replace(/(\d)(?=(\d{3})+\b)/g, "$1,");
first it matches "1", replaces that with "1," - matches the whole string but only remembers the first number.
second it matches "4", replaces that with "4,"
finally it matches "7", replaces that with "7,".
So the RegExp actually matches from left to right. I didn't notice before because the example on that page uses a string that is a list of numbers separated by spaces, and I over-looked the +. With only one number this works as well...
/(\d)(?=(\d{3})+$)/g

Note that if the number was "01234567890", the first "0" would not match the expression, so it would skip to the next number.

 
Mar 26, 2008
Descriptor 757 posts

Topic: Script development / split

I never really looked at that RegExp before, it's actually very efficient. I never realized that excluding a matched group would also exclude that group from being replaced. I think the RegExp in this case is faster.
/(\d)(?=(\d{3})+\b)/g searches for 4 digits that end in a non-word boundary (\b), starting at the left of the string, the first digit being replaced by itself followed by a comma.
The next search (caused by g) will match 4 digits up to that comma just added, etc. The part that eludes me is the +, which is what allows it to work. This probably only run 2 or 3 iterations, depending on the length of the string of course, and the search gets shorter each time, and no variables are created. Also it naturally converts a number to a string.

Your function above creates 4 variables. It creates an iteration that evaluates the string length on each iteration (which you could avoid by creating yet another variable). Once I replaced a RegExp with a substring method and it was apparently slower, so I improved the RegExp, though I would also expect substring to be faster, it probably depends more on how efficient the statements are.

In one case I just wanted to see if a file size was larger than 1M, so I did this
filesize = filesize.replace(/(\d+)(\d{6})$/,"$1" + "," + "$2");
which I see from the above example can be reduced down.

 
Mar 25, 2008
Descriptor 757 posts

Topic: Script development / Noob Question

You don't want to search the source of a page, either you search for elements or attributes and/or textContent.
If an image is added to the page by a script, then it's probably going to be in the document.images list (that example looks wrong, but anyway you want the src property of the image).
Once you found what you want you just change the location.href

 
Mar 25, 2008
Descriptor 757 posts

Topic: Ideas and script requests / A MUST SEE!!!!!

Heh, all you have to do is search for "UserScript". Must be too easy.

 
Mar 25, 2008
Descriptor 757 posts

Topic: Ideas and script requests / A unique hover pop up script

Relentless, crafty Google searching turns up all kinds of useless info.

 
Mar 25, 2008
Descriptor 757 posts

Topic: Script development / Autofill

but you'd be surprised at the lack of good Javascript tutorials there are on the internet.

actually, surprised by the overwhelming number of bad tutorials. Of course, since IE isn't kept up-to-date why should anyone bother?

 
Mar 25, 2008
Descriptor 757 posts

Topic: Ideas and script requests / A unique hover pop up script

Yes, I wouldn't have wasted so much time in my answer if I knew that ahead.
the proper reference would be: http://www.vbulletin.org/forum/showthread.php?t...
and the place to ask the question: http://www.simplemachines.org/community/index.p...

 
Mar 22, 2008
Descriptor 757 posts

Topic: Script development / how to edit a table?

Why add style attribute when you have a class name?
GM_addStyle("table.calendar {margin: 1% auto}");
or use Stylish.

You can use min-height for a table, but you'll have to define a few other things, likely vertical-align: bottom; padding: auto; and maybe min-height for each cell, and there is no definition for "percentage" in table or cell heights. However you could use em which refers to line height (or width of "M", and ex is height of "x"), but is equal to the font size. I haven't messed with it much since it's totally inconsistent across browsers.

 
Mar 22, 2008
Descriptor 757 posts

Topic: Userscripts.org discussion / Encoding in comments

Turn off Greasemonkey and look at this comment:
http://userscripts.org/scripts/show/22569#34552
it looks fine to me.

Why don't you just post this in the script description where you can edit it?

 
Mar 22, 2008
Descriptor 757 posts

Topic: Script development / how to edit a table?

There is no "height" for tables: http://www.w3.org/TR/html401/struct/tables.html...
So changing it will likely have no effect.

 
Mar 22, 2008
Descriptor 757 posts

Topic: Script development / Problems installing Profanity Filter

http://wiki.greasespot.net/Greasemonkey_Manual:...

Read that part about "Edit the Script". They don't really explain how to edit someone else's script, but just ignore the part about creating a new script, you don't need to do that. However if you reinstall the script when it gets updated, you will lose any changes you made. You can save a copy and change the @name and maybe change the @namespace. Then just Use File -> Open to install the renamed script, disable the original. Now you have your version and the original, so you can use or edit either one.

Also you could probably drag the script file into an empty browser window, then the Greasemonkey install dialog should pop up. Like I said, you should probably change the @name if you don't want script updates to erase what you changed, or you can save the updated script to disk and copy your changes then use File -> Open again. Which ever you prefer.

 
Mar 22, 2008
Descriptor 757 posts

Topic: Ideas and script requests / A unique hover pop up script

I think I registered there. But anyway, if I had the time I could do this, it can certainly be done with XMLHttpRequest.
You want this to work on other forums, correct? That forum uses server-side code to generate the list of images that show in the pop-up, Greasemonkey would have to use XMLHttpRequest to parse the gallery page and get a few image thumbnails, searching for src "imagevenue.com/loc" or better yet /imagevenue\.com\/loc\d+\/th_/i.

 
Mar 21, 2008
Descriptor 757 posts

Topic: Userscripts.org discussion / Encoding in comments

Hey! Now your code is correct in http://userscripts.org/forums/3/topics/1994#pos...
I turned off my syntax highlighter and what you typed is now correct. If I turn it back on and reload then the entities turn back into > and < . Interesting.

My code is correct either way.

 
Mar 21, 2008
Descriptor 757 posts

Topic: Userscripts.org discussion / Encoding in comments

Also, I found if you use a block element or BR element just once, that it will mess everything up, you have to use blocks around everything, BR or P tags to add line breaks and preserve formatting.

 
Mar 21, 2008
Descriptor 757 posts

Topic: Userscripts.org discussion / Encoding in comments

Oh I missunderstood what you are doing, I get it now. Just use formatting tags around the &
string.replace(/>/gmi, "&gt;").replace(/</gmi, "&lt;");
That worked, I typed this (surrounding specials in I tags for this example below)
<code>string.replace(/&gt;/gmi, "<i>&</i>gt;").replace(/&lt;/gmi, "<i>&</i>lt;");</code>

Also try to use spaces if you can like with if(i < j) so it doesn't look like a tag.

 
Mar 21, 2008
Descriptor 757 posts

Topic: Ideas and script requests / PdfMeNot redirect ?

http://wiki.greasespot.net/Greasemonkey_Manual:...

 
Mar 21, 2008
Descriptor 757 posts

Topic: Userscripts.org discussion / Encoding in comments

Place it in <code> tags and use entities for <

 
Mar 21, 2008
Descriptor 757 posts

Topic: Script development / Useful code snippets

http://developer.mozilla.org/en/docs/DOM:elemen...

http://developer.mozilla.org/en/docs/Whitespace...

 
Mar 21, 2008
Descriptor 757 posts

Topic: Ideas and script requests / SurfTheChannel

Though I really hate low quality video, that site isn't too bad, nice that way they have everything organized. I was able to find Dexter with no trouble.

Using LiveHTTPHeaders I was able to get the URL of the video and download it with my download manager, however I had to enter a file name to save the file as. And the video was 16/9 and the only flv player that would let me change the aspect ratio was Video Lan.

With the above info a scriptwright should be able to figure out how to create a link, or there may already be one that works. Not really interested myself, more interested in HD.