Thursday, 4. January 2007, 03:26:41
[UserJS] MyOpera Community Enhancements — Versions 1.20+
I created the original post under the impression I'd be able to edit it with an updated title as new versions were released. Then a 24-hour time-limit was placed on editing posts. So I've created a new thread better designed for such restrictions.My Opera Community Enhancements
A script by xErath and BtEO
A short history:
This script resulted from a post xErath made in the UserJS forum. While he had been coding this, I had also been working on my own set of toys to improve life here. My own standards precluded my releasing the messy code I had, but in this post I saw an opportunity to gain motivation.
We began to collaborate and agree on a feature set for version 1.00, which was released in that thread, and submitted to userjs.org. I had originally planned to wait until the script got accepted at userjs.org before placing an announcement here; but at the moment they have more important things to do, and I could wait no longer given the progress to version 1.10 and beyond.
The script is a suite of toys that improve various tasks at these forums, the basic functions break down as follows. Each part can be enabled independently of its fellows, and there are many more configuration options within the script. Always check later posts, and the file itself, for the most up-to-date information about the tools available.
Search Results Cleaner:
cleanresults.png
This tool looks through the results pages of any search (also including pre-baked searches such as the unread posts, my active topics, etc...) and highlights (with a user-definable colour) on those listings any post from a forum you have chosen to highlight in search results.
Forum List Cleaner:
cleanforum.png
This tool processes the main forum listing (and the listing of any group you might subscribe to.) You can hide any forum you wish from the listings (I hide all those operating system specific ones that do not apply to me) or, much as with search results, highlight a forum on the listings. Highlighting is configured independently of those highlighted on the search results (although they share a colour configuration.) Should you hide all of the forums from a particular grouping, that group will also be hidden.
Extra Smileys:
smileyextra.png
This tool does two things. When making or editing a post anywhere except the quick reply field, It will add code so that the smileys are preloaded with the page (a cosmetic thing to be sure, but it is jarring to open the panel and see numerous placeholders temporarily.) It will also add any known hidden smileys to that panel.
This feature also works on blogs
Show Smiley Code:
smileycode.png
The tool adds a title to every smiley on a page. Curious as what text triggers a given smiley? Now simply hover the image in question and let the title tell you.
This feature also works on blogs
Inline Attachments:
showattachment.png
This tool will take image or text attachments (as you desire,) and display them inline underneath the attachment link. The inlined attachments can be hidden by default. You can also control the height of the inlined content, with anything larger gaining a scrollbar.
This feature also works on blogs
Classic Forum View:
classicforum.png
The default forum view at http://my.opera.com/community/forums/ is nice looking, but some people may prefer a more classic forum style with information such as thread counts, and who posted last. Fortunately, one already exists here at http://my.opera.com/community/forums/home.dml. This tool will ensure that the classic view is the one you use. This tool is OFF by default.
Page Numbers:
pagenumbers.png
Some forum systems include page numbers underneath threads large enough to have more that one page. Before the site redesign there was a userscript that added that here; so we resurrected that script's functionality[1]. The script grabs your currently defined posts-per-page value automatically and stores it in a cookie. It will in theory keep track should you change that value, and in the event of losing sync, the cookie is only given three days life whereupon the figure will be updated once more. If you have cookies disabled, you can hard-code the value in the script, much as with it's predecessor.
File Size Conversion:
filesizes.png
This tool converts the file sizes listed on your 'my files' page from bytes into friendlier units. (KiB, MiB,...)
Quick Message Inbox Link:
messageinbox.png
This tool adds a quick link to the inbox for your community messages.
Convert Tabs To Spaces:
The design of the forums means tabs are stripped from posts on submission. This tool converts them to spaces before that happens to preserve any intentional indenting. The tab width is customisable, with the default being 4.
Hide Friends' Latest Posts:
latestfriends.png
This tool removes from the main forum page the 'My friends' latest posts' box. Naturally it has no effect if you're using the classic forum view. This tool is OFF by default.
Un-Highlight Friends' Posts:
friendshighlight.png
This tool remove the highlighting applied to all of your friends' posts. This tool is OFF by default.
The script is also configured by default to check for new version once a day (assuming you visit the Opera Community at least once a day). This can be disabled as with any other preference.
One final feature is support for an external preferences file[2] (credit goes to Hesido's MultiPopup for the idea.) Many scripts have configuration, but any changes you make have to be redone with each new version. Given the number of options here this is clearly unacceptable. Full instructions on how to create such a file are included in comments at the top of the script, but I include a sample version below.
Note that unlike MultiPopup's external settings, this one only overrides defaults. This means that if a future version of the script adds a new setting you do not need to add it to your settings unless the default is undesirable.
With all that said, the script (as an attachment, so you can even see it in action by reloading the page):
myopera-community-enhancements.js
And an external preferences file.
myopera-community-enhancements-prefs.js
All future versions of the script will be announced in a new post in this thread, but the attachment in this post will always be the most current version. Remember to read below for information on updated versions.
[1] Note: The code used here is written from scratch. I could not even tell you who wrote the original, nor tell you where to find that code. But thanks for the idea, whoever gave it to us.
[2] The external preferences file may need to be loaded before the main script in order to work properly. Opera reads and loads the files in the order reported by the operating system. On Windows 2000/XP systems this will always be alphabetical order. On Windows 9x/ME it will be the order that the files were created.
Friday, 5. January 2007, 02:21:55 (edited)
Friday, 5. January 2007, 00:52:26 (edited)
Thanks for the requested feature: 'Would rather not have "My friends' latest posts" on Opera Forums page'
... not to mention the other updates...
Saturday, 6. January 2007, 01:58:28 (edited)
~~~~~~~~~~~
Edit
Now I'm confused-- don't worry we'll catch on sooner or later...
Is v 1.21 only the external file, or do both .js files have a version 1.21? I didn't look carefully enough when the update popped up
~~~~~~~~~~~
Edit
Nevermind & thanks!
Saturday, 6. January 2007, 01:51:52
The update check checks a file in his storage, and he will update his copy of the script at the same time presumably. But the original post links to copies on my storage.
Consider the version on my storage (and at the top of the page) a stable copy.
Those willing to keep track of a development versions should look in xErath's files.
Anyway, changelog for 1.21:
# image attachments now load always, if they're in cache # pressing backspace or delete work in textareas, if the choice to replace tabs with white-spaces is active # other things I don't recall :) * replace tabs with spaces feature disabled by default * script url moved to configuration variable, for new version check
p.s. Nice to know the replace tabs with spaces feature does work (I pasted the above changelog with tabs in it).
Saturday, 6. January 2007, 04:52:41 (edited)
Changing a couple preferences was quick and easy, the page numbers appear to be correct, good job!
I have one request and one problem, both related to the PM flag.
Request first:
The PM flag used to come up only when I have unread messages, now it is there full time, can the old behavior be reinstated?
Problem:
The PM Flag link identifies my user name as "SADDLE+MAGIC", this is incorrect and non-functional as a space must be identified as "%20", the "+"(plus sign) does not work.
EDIT: Nope, guess I lied there. I am optioned to display 100 posts per page, the page numbers reflect 20 posts per page.
Saturday, 6. January 2007, 07:40:13 (edited)
Originally posted by Saddle Magic:
The script should read the proper value from your settings page.EDIT: Nope, guess I lied there. I am optioned to display 100 posts per page, the page numbers reflect 20 posts per page.
Search for the cookie UJSMOCFEPostsPerPage and tell me its value..
and I think I know where the bug comes from...
Try my version (with the bug fixed... probably). myopera-community-enhancements.js
Saturday, 6. January 2007, 09:37:02 (edited)
A few suggestions along the lines of this script:
all apply to http://my.opera.com/community/forums/
hide Active Forum Topics:
if (hideActiveForumTopics)
addCssToDocument('#aft{display:none}');
hide Most Spotlighted Topics:
if (hideMostSpotlightedTopics)
addCssToDocument('#mst{display:none}');
hide Language Specific Forums:
function doHideLanguageSpecificForums() {
document.selectSingleNode('//h3[contains(text(),"Language specific forums")]/..').style.display = 'none';
}
...
if (hideLanguageSpecificForums)
addDOMLoadedEventListener(doHideLanguageSpecificForums)
Saturday, 6. January 2007, 17:38:33
Thanks xEarth so much
--- Thanks for reading --- ((( Nxqd3051990 ))) < Time never get back >
Saturday, 6. January 2007, 18:47:03
Originally posted by xErath:
Search for the cookie UJSMOCFEPostsPerPage and tell me its value..
That cookie is set to "100".
Looking at the other script now.
Saturday, 6. January 2007, 19:46:37
I see no changes:
- Page numbers display 20 posts per page, I am set at 100.
- PM flag link to messages still wrong.
I did restart Opera after changing the script.
Another problem I was finding with the new enhancement script:
After installing BtEO's enhancement script I was started noticing a problem with forum pages becoming unresponsive. I keep the Community Forums page open as well as several individual forums, I will then reload one or all of them occasionally throughout the day looking for new posts, opening individual threads in new pages and closing them when done.
The pages I keep open long term stopped responding, they would not reload and none of the buttons, links and even bookmarks would not open on these pages. Not all of them at once and not right away, first one then another. The pages looked right and I could scroll through them, just nothing would work. I had to close these pages and reopen in a new page to continue.
Total I saw this in 5 or 6 pages, only Opera forum pages were effected. I will watch for this if it continues and gather what I can about what is happening.
Is there anything specific I should check?
Sunday, 7. January 2007, 00:28:52 (edited)
You could try disabling all of the various tools, and then re-enabling them one-by-one until the problem returns.
However, I think I know exactly what your issue is with the posts-per-page not being read correctly. I had even preemptively fixed it months ago at my end, but forgot I had done so meaning the changes didn't get merged when xErath did his big update. I'll have a new version up for you to test shortly.
Edit:
Saddle Magic (and others)
If you could test this version myopera-community-enhancements.js
Please delete any existing 'UJSMOCFEPostsPerPage' cookie values and make sure the script gets the correct username. When you reload any forum page it will be placed in that cookie in the form: <#postsperpage>_<username>. e.g. 50_BtEO
Post here if it doesn't work as intended.
Sunday, 7. January 2007, 01:48:28
Before I got the chance to delete the cookie the page numbers are showing correctly
My user name in the PM flag is also fixed
I'll watch for the unresponsive thing and post here with details.
Any thoughts on having the PM flag only appear when there are unread messages?
Sunday, 7. January 2007, 23:20:46
Given the no apparent issues with the fixed code that version is now released as 1.22
Changelog:
# Improved code for obtaining the username of the current user.
Sunday, 7. January 2007, 23:36:15
No signs of any problems
Thanks
Monday, 8. January 2007, 01:26:55
Originally posted by BtEO:
Just set showMessageInboxLink to false in your preferences.
Will it still flag new messages or does it completely inactivate the flag? Ie is it "always or never" or does it work correctly when new PMs show up?
Monday, 8. January 2007, 01:42:20
Originally posted by Saddle Magic:
Yes it does
Ummm... it was an "or" question. Do you mean that the PM flag goes away, but shows up correctly when a new PM arrives? (am assuming "Yes it does" & fixing accordingly)
Monday, 8. January 2007, 01:56:21
When you have an unread PM the flag shows itself, then dutifully goes away when no unread messages are in attendance.
Tuesday, 9. January 2007, 12:04:18
Tuesday, 9. January 2007, 17:28:15
The script makes extensive use of DOMContentLoaded events. If I recall correctly Greasemonkey won't have even tried to run the script (or can't be guaranteed to have done so) at that point.
Thursday, 11. January 2007, 04:33:39
Originally posted by Saddle Magic:
When you have an unread PM the flag shows itself, then dutifully goes away when no unread messages are in attendance.
I have multiple read messages in my inbox (0 unread). According to the code:
if (showMessageInboxLink ) addDOMLoadedEventListener(doShowMessageInboxLink);it doesn't seem to check whether i have messages or not. I assume it would have to make an xmlHttpRequest call to
to accurately show/hide the icon and link'http://my.opera.com/'+username+'/messages/'
Topic #2: (totally unrelated)
For efficiency's sake, shouldn't this portion of the code:
if (classicForumView) {
addDOMLoadedEventListener(convertForumLinks);
if (location.href.match(/community\/forums\/(index\.dml)?$/)) // Prevent refresh.
location.replace(convertOneForumLink(location.href));
}be the first thing checked for since it will load a new page and cause everything above it to be checked for/run a 2nd time?Thursday, 11. January 2007, 20:26:27
Originally posted by philry4n:
That's out of this scripts jurisdictioncan this be implemented in other website, maybe just the emoticons? so if there's a text in another site like :
Originally posted by fearphage:
For efficiency's sake, shouldn't this portion of the code:
Saturday, 13. January 2007, 06:05:44 (edited)
For example, the Lounge group:
http://my.opera.com/lounge/forums/forum.dml?id=34
-- vs --
http://my.opera.com/community/forums/forum.dml?id=34
Saturday, 13. January 2007, 22:10:35
double_image.jpg
EDIT: Ok... I have no idea how to explain it, but my attachment image to THIS particular post isn't showing twice. But you can see from the picture that it happened to the very first post (and still does). Very weird.
Saturday, 13. January 2007, 22:44:51 (edited)
Saturday, 13. January 2007, 22:44:58
bug: The function that should fix the scrolling is not working. I was typing this and when the pictures loaded I was looking at about 7 posts back. I haven't looked at the function but I will later to see if I can pinpoint the issue. Can anyone confirm this one?
Saturday, 13. January 2007, 23:11:59
Originally posted by fearphage:
I haven't looked at the function but I will later to see if I can pinpoint the issue. Can anyone confirm this one?
I have changed the option, so images and text attachments display minimized, this way I can show them if I want and they don't displace text on the screen. This used to be a problem with older versions of this script, when you go to the last post on a page with lots of attachments, when the page finishes loading you had to scroll quite a distance to get to where you wanted to be.
Sunday, 14. January 2007, 00:23:37
I had the script from this topic installed (myopera-community-enhancements.js). Then I *also* had a script called opera-community-enhancements.js installed. It had a modify date of last March. I guess it was an older version that I never renamed to .bak or deleted. Heh. My bad.
Sunday, 14. January 2007, 00:29:22
Saddle Magic, this comes back to a variant of the bug you experienced before. (It actually works fine in my case, but you'll be able to see why as I explain below)
The script tries a number of methods to find out the current user name.
First it will look to see if you are on the forum settings page, it can then grab your username from the current URL. (You're not.)
Then it looks for the "My Page" link, and will attempt to extract the user name from that. (No "My Page" link in the standard place on the custom lounge version.)
Should both of those fail it will grab the username from a cookie, this would be first but for a couple of problems. (The username is stored as-typed when logging in, so if I'd typed bteo rather than BtEO when logging in, it wouldn't work. The username is also stored with form encoding, e.g. '+' == ' ' which is the bigger problem in your case.)
A future versions will will know to look for the "My Page" link in a different place on group specific forum listings; and hopefully future versions of the Opera Community will store a more accurate user name in the 'opera_persistent_uid' cookie.
Sunday, 14. January 2007, 00:48:39
Thanks for the explanation
Sunday, 14. January 2007, 01:13:00
In the meantime you could locate the getUsername() function in your copy of the script and replace it with:
var getUsername = function (pageCookies) {
usernameChecked = true;
return "Saddle Magic";
}
Sunday, 14. January 2007, 01:55:47
//var getUsername = function (pageCookies) {
//var usernameLink, foundUsername, loginbox; // Default username to blank string.
var getUsername = function (pageCookies) {
usernameChecked = true;
return "Saddle Magic";
}
But now I have lost page numbering completely
Sunday, 14. January 2007, 03:37:44
The getUsername() function in its entirety:
var getUsername = function (pageCookies) {
var usernameLink, foundUsername, loginbox; // Default username to blank string.
var loginBox = document.getElementById('loginbox');
if (loginBox && (loginBox.class == 'loginnow')) { // User not logged in.
usernameChecked = true;
return '';
}
// Have we already found it?
if (window.username) {
foundUsername = window.username;
}
// Attempt to get from current URL (if on forum settings page)
if (usernameLink = location.href.match(/http:\/\/my\.opera\.com\/([^\/]+)\/account\/forumsettings\.dml/)) {
foundUsername = usernameLink[1];
}
// Attempt to get from 'My Page' link.
else if (loginBox && (usernameLink = loginBox.getElementsByTagName('a')[0])) {
foundUsername = usernameLink.href.match(/http:\/\/my\.opera\.com\/([^\/]+)\/$/)[1];
}
// Try and grab from a cookie.
// Only works when user has checked the 'remember me' box,
// and logged in with their username in the correct case.
else if (!username) {
foundUsername = pageCookies['opera_persistent_uid'];
}
// Return blank string.
else {
foundUsername = '';
}
usernameChecked = true;
return foundUsername;
}Comment out all of that, and replace with the code I gave.Monday, 15. January 2007, 02:00:10
Originally posted by fearphage:
bug: The function that should fix the scrolling is not working. I was typing this and when the pictures loaded I was looking at about 7 posts back. I haven't looked at the function but I will later to see if I can pinpoint the issue. Can anyone confirm this one?
It happens seldom.... I can't tell why. But overall the page scrolling is working fine.
Tuesday, 16. January 2007, 01:25:53
showMessageInboxLink false ?
It's a little irritating to have to change it with every update...
Tuesday, 16. January 2007, 01:43:02
Originally posted by aimzz:
Is there a reason that the default is not
Probably the same reason that,
showImagesMinimized : true
showTextMinimized : true
are not the the default values. The default has to be something.
Tuesday, 16. January 2007, 01:47:22
Originally posted by xErath:
I have never seen the scroll work correctly. Could you show me a page where it works correctly for you? This page, for instance, consistently requires me to scroll back down once it loads.It happens seldom.... I can't tell why. But overall the page scrolling is working fine.
Showing topic replies 1 - 50 of 313.
Forums » Opera Community » General Opera topics » Customizing Opera
