afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
[personal profile] afuna
In case anyone wants to comment on the script but doesn't feel comfortable doing so on us.o, here is a good place. I'm assuming that anyone who wants to use that script has an LJ account, since the script itself is made to work with LJ!

---

Because it seems fitting, here's a script (not written by me!) which restores the appearance and formatting of the old update.bml page.

Also, I've finally posted the script to add a tagslist to update.bml. There's an easter egg in there of a sorts -- didn't bother to remove my uglification code, but it can't be activated unless you know the exact steps.

Ah, the stupid thing is that my script is not compatible with the first one, so unless someone (else) is willing to figure out how to fix that, you'll have to choose one or the other.

The information below is outdated; most updated info is in the script itself and probably also in the extended description over at us.o.

The script will probably contain the most updated form of this, but here goes:

Usage notes:

  • will only work with journals you can edit via the Tags Management page, sorry! That means your own personal journal and any communities you manage. Trying to do it any other way would require parsing the tags page of the journal, which I'm not quite up to

  • cmd-clicking /ctrl-clicking on the tags will open the tagspage in a new tab

  • when expanded, the list shows all tabs. When collapsed, it shows the top $n tags based on usage frequency, where $n is a number you define. If there are many tags tied for $nth place, it shows all of them

  • there is no auto-complete, and it will not synchronize the textbox and the list when input is typed. However, it should always synchronize on click

  • the tags list will show up in both when you update and edit. It will also automatically detect the journal you're posting to


Random notes:

  • If you're wondering where I grab the tags info, I get it from the tags management page which has an array of tags and tags data

  • was thinking of caching the tags, but then I remembered that GM has a problem with UTF-8 encoding, and I think that certain languages require UTF-8. Would rather not risk it

  • does not work with the script that restores the old update.bml appearance. Both of us move things around using javascript, so, um, yeah. Might be possible to integrate the two though

  • There is a hidden uglification setting built in which moves the icon to the bottom and removes music/location textfields. I've deliberately hidden it because I plan to use it, but I don't think anyone else would appreciate it

  • if anyone should want to grab any part of this and use it for any reason, say to merge with another script, then go ahead (do I even have to say that? *g*). However, if you discover any bugs when you take the code, please email me at my livejournal.com email

  • I need to clean up my code


Changelog:
2007.01.07
  • fixed bug where "&" were showing as "&" (thanks to turloughishere for pointing it out)
  • changed whitespace in the tag url to a '+', in keeping with the tag url conventions on LJ
  • there is no journal dropdown when you're logged out, so check whether it exists or not
2007.01.16
  • remembers whether you have the tagslist expanded or not

Date: 2006-12-21 03:21 am (UTC)
From: [identity profile] iruka11.livejournal.com
may problema sa encoding? hmmm... may tag kasi akong nakajapanese... pano kaya un?

Date: 2007-01-18 04:23 pm (UTC)
From: [identity profile] soph.livejournal.com
I've just had a thought regarding the taglist script... might it be a good idea to get the tags by scraping the appropriate /tag/ page for A tags with hrefs matching /^http:\/\/afuna\.livejournal\.com\/tag\// within the "ljtaglist"-classed UL, and getting the text within those tags?

That way you don't need to bother with the Tag Management page - and even though you'd only see the tags from posts that you're allowed to see, you wouldn't get any more info from the Tag Management pages anyway since you'd be able to see all the tags in any case.

I could try to write up some code for you to do this if you want.

Date: 2007-01-18 04:24 pm (UTC)
From: [identity profile] soph.livejournal.com
And, of course, I meant /^http:\/\/.*\.livejournal\.com\/tag\//, sorry. ;p

Date: 2007-01-19 12:17 pm (UTC)
From: [identity profile] soph.livejournal.com
Okay, I've been hacking at the code and I've got something that pretty much works. It uses a few hacks in places, and there's one community in particular that it fails on that I just can't work out why (more on that in a bit), but it works on other communities just fine.

Here's the URL:
http://matrix.theblob.org/greasemonkey/ljtaglist-ciaran.user.js

The community that it doesn't work on is 'supportlounge', which is a community for LJ Support volunteers to relax in. The errors I'm getting are *weird*:

Error: illegal character
Source File: http://www.livejournal.com/js/core.js
Line: 1
Source Code:
⼪੃潲攠䩡癡卣物灴⁌楢牡特ਤ䥤㨠捯牥⹪猠㠵′〰㘭ㄱⴱ〠〰㨴㤺ㄴ娠橲慭獥礠␊੃潰祲楧桴

Error: illegal character
Source File: http://www.livejournal.com/js/dom.js
Line: 1
Source Code:
⼪੄位⁌楢牡特‭⁃潰祲楧桴′〰㔠卩砠䅰慲琊⑉携⁤潭⹪猠㠶′〰㘭ㄲⴰ㐠㈱㨳㔺〷娠桥湲祬祮攠␊੃潰祲楧桴

Error: illegal character
Source File: http://www.livejournal.com/js/httpreq.js
Line: 1, Column: 2
Source Code:
癡爠䡔呐剥焠㴠湥眠佢橥捴㬊ੈ呔偒敱⹣牥慴攠㴠晵湣瑩潮

Error: DOM is not defined
Source File: wyciwyg://23/http://www.livejournal.com/update.bml?mode=full
Line: 33

Error: illegal character
Source File: http://www.livejournal.com/js/??core.js,dom.js,httpreq.js,livejournal.js,common/AdEngine.js,ippu.js,lj_ippu.js,hourglass.js,contextualhover.js,livejournal-local.js?v=1165880009
Line: 1
Source Code:
⼪੃潲攠䩡癡卣物灴⁌楢牡特ਤ䥤㨠捯牥⹪猠㜳′〰㘭〷ⴱ㜠ㄷ㨱㠺㐷娠浩獣桡․ਊ䍯灹物杨琠⡣⤠㈰〵Ⱐ卩砠䅰慲琬⁌瑤⸊䅬氠物杨瑳⁲敳敲癥搮ਊ剥摩獴物扵瑩潮⁡湤⁵獥⁩渠獯畲捥⁡湤⁢楮慲礠景牭猬⁷楴栠潲⁷楴桯畴੭潤楦楣慴楯測⁡牥⁰敲浩瑴敤⁰牯癩摥搠瑨慴⁴桥⁦潬汯睩湧⁣潮摩瑩潮猠慲攊浥琺ਊ††⨠剥摩獴物扵瑩潮猠潦⁳潵牣攠捯摥畳琠牥瑡楮⁴桥⁡扯癥⁣潰祲楧桴੮潴楣攬⁴桩猠汩獴映捯湤楴楯湳⁡湤⁴桥⁦潬汯睩湧⁤楳捬慩浥爮ਊ††⨠剥摩獴物扵瑩潮猠楮⁢楮慲礠景牭畳琠牥灲潤畣攠瑨攠慢潶攊捯灹物杨琠湯瑩捥Ⱐ瑨楳楳琠潦⁣潮摩瑩

Warning: Unexpected end of file while searching for ',' or '{'. Ruleset ignored due to bad selector.
Source File: http://stat.livejournal.com/??lj_base.css,contextualhover.css,controlstrip.css,controlstrip-dark.css,controlstrip-dark-local.css,controlstrip-local.css?v=1165624698
Line: 1

Warning: Unexpected end of file while searching for closing } of invalid rule set.
Source File: http://stat.livejournal.com/??lj_base.css,contextualhover.css,controlstrip.css,controlstrip-dark.css,controlstrip-dark-local.css,controlstrip-local.css?v=1165624698
Line: 1


There doesn't seem to be anything screwy with any charset declarations in http://community.livejournal.com/supportlounge/tag/ as far as I can see, and it works for other communities - just not that one. I have no clue what's going on... any ideas?

Anyway, hope you find it useful.

Date: 2007-01-19 12:28 pm (UTC)
From: [identity profile] soph.livejournal.com
You know what, I bet something's screwy with the gzip content compression in that exchange. I haven't tested this idea but I bet the CJK characters being seen there are the gzipped exchange being interpreted as UTF-8. I still have no clue for why it would refuse to work solely for supportlounge, however.

Date: 2007-01-19 12:30 pm (UTC)
From: [identity profile] soph.livejournal.com
Wait, no, that can't be it. If that was it there would be a LOT more invalid characters. It's asking too much that a gzip exchange would all be perfectly valid UTF-8 characters.

Meh. Sorry for the comment spam, I'll shut up now until I can work something out.

Date: 2007-01-19 03:16 pm (UTC)
From: [identity profile] soph.livejournal.com
Awesome find! Yeah, that makes things a lot easier to deal with, and more reliable to boot. It also means I don't have to deal with tagstable; I added it for categories like http://community.livejournal.com/learn_support/tag/ , where the tag information is shown in a table.

I've cleaned the code up a bit and the new version is at http://matrix.theblob.org/greasemonkey/ljtaglist-ciaran-2.user.js . I know you know how to do this yourself but I also wanted to get rid of some commented out stuff, etc. :)

Just one thing to mention; this was just a quick hack, so to save myself the bother of rewriting the rest of your code, I tried to keep tagNodes and frequenttags using the same list format as before. It does mean that the 'security' information is useless now, though; you may want to clean that up and remove that, since there's no way to get that information through /tag/ .

Thanks for the feedback! :D Glad you found it useful.

Date: 2007-01-19 04:12 pm (UTC)
From: [identity profile] soph.livejournal.com
I noticed that you ordered the tags by their usage frequency -- do you think it's likely that most others want it the same way? Right now I'm doing it alphabetically so that it's easy to find a tag in the list of tags if you don't know the usage patterns of the community, but that means that the frequently used tags are hidden among all the other tags. Granted, you can pull up the top $n or so tags, but...

That was most likely a mistake on my part. I was trying to emulate the way you did it, which I figured was by the frequency. I agree it'd be easier alphabetically, yes.

Here's a suggestion, though, that might help with the most common tags being hidden. Maybe you could make the textbox serve a dual purpose - as well as changing the number of items shown when the list is collapsed, make it so that when the list is expanded, those same tags are instead put in bold. It's probably easier to do the necessary bolding on load and on a change of the textbox, which means that a collapsed list would have all its tags in bold. But to be honest, I'd be fine with that; it reinforces the idea of what the bold tags actually represent.

One thing though, I'd recommend using .textContent and not .innerHTML when fetching the tagname from the server because .innerHTML escapes the & to an &.

Actually that's what I'd normally have done but when I edit other people's code I try to stick to what they're doing themselves. (Actually, normally I tend to refer to things directly rather than using .innerHTML or .textContent, but, heh.) I'd noticed that you were using innerHTML to get the contents of the <script> tag, so to make things easier I adopted that throughout. (Besides, as I said before, it was a quick hack. ;p) Had I looked in the other functions I'd have seen that you used .textContent, but I had no need to.

I could have sworn that I tried ?format=light before, and that it didn't work, but I might have misremembered. Or something might have changed. Either way, I'm not complaining!

Actually, I think either something changed or we're both misremembering things - I thought I'd tried it before too. But I may just have tried it on my journal, which, by virtue of its being S1, is already in the requisite format.

Or we might have both been trying ?usescheme=global or something similar, which doesn't work.

Date: 2007-01-19 04:15 pm (UTC)
From: [identity profile] soph.livejournal.com
Oops, didn't get to finish my comment...

That was what was stopping me before: the variety of styles. Your first comment on the subject made me think of pulling up any link that was in the proper format, instead of looking up specific divs/uls since those vary by styles, but with tagslists in the sidebar, there would be twice as much processing.

My view of it is that I believe the tag lists are generated. Or believed, anyway; I'm not so sure now. I figured that all tag lists would have the "ljtaglist" class, and nothing else would; obviously this turned out to be wrong with "tagstable" and tag lists in the sidebar. But yeah, using ?format=light is definitely much better.

BTW, apologies for answering in reverse order - that's the way I like to do things, heh.

Are you on IM at all? You sound like the sort of person I'd like to geek out with. ;p