Page 1 of 1

Script to Hide Poorly Rated Webteases

Posted: Mon Jul 04, 2011 9:50 pm
by g[mx]
Hey there Milovana,

Being annoyed by poor or self-advertising teases, I've decided to write a little script which hides all poorly rated teases (less than 2.5 stars) in the webteases browser.

If anyone else wants to use it, it's designed for Firefox 4 or 5 with the Greasemonkey Add-On (you need to install this first) or any recent version of Google Chrome.

To install the script just click on this link: http://gmx.bplaced.net/badtease.user.js
Or save the following code as textfile named "badtease.user.js" and drag it over your browser:
Spoiler: show

Code: Select all

// ==UserScript==// @name          Hide Bad Teases// @namespace     milovana// @description   Hides poorly rated webteases on Milovana// @include       http://www.milovana.com/webteases/*// @match         http://www.milovana.com/webteases/*// ==/UserScript== var MIN_RATING = 2.5; function init() {    document.        getElementById("tease_list").        addEventListener('DOMNodeInserted', hideTeases, false);    hideTeases()} function hideTeases() {    var teases = document.getElementsByClassName("tease");    for(var i=0; i < teases.length; i++) {        var rating = teases[i].getElementsByClassName("rating_text")[0].firstChild.data;         if(rating < MIN_RATING && !teases[i].tagged) {            teases[i].tagged = true;                        var replacement = document.createElement("div");            var toggleLink = document.createElement("span")            var text = document.createTextNode("Hidden Tease (Rating: "+rating+")");                        toggleLink.addEventListener('click', (function(tease) {                 return function () {                    tease.style.display = (tease.style.display == "none") ? "block" : "none";                }            })(teases[i]), false);                        replacement.appendChild(toggleLink);            replacement.className = "tease_toggle";                        teases[i].style.border = "1px dashed #933737";            teases[i].style.padding = "4px";                        toggleLink.appendChild(text);            toggleLink.className = "fakelink smallprint";                        teases[i].parentNode.insertBefore(replacement, teases[i]);            teases[i].style.display = "none";        }    }} if(document.body) {    init();} else {    document.addEventListener("DOMContentLoaded", init, false);} 
It's a "works for me" solution, but maybe it's useful for someone else. If you want to change the rating threshold, just change the value of the "MIN_RATING" value on line 9.

Re: Script to Hide Poorly Rated Webteases

Posted: Mon Jul 04, 2011 11:01 pm
by SexualChoc
Now THAT is a good idea!

Thank you very much!

Re: Script to Hide Poorly Rated Webteases

Posted: Tue Jul 05, 2011 3:40 am
by Azureballs
Thank you!

Re: Script to Hide Poorly Rated Webteases

Posted: Tue Jul 05, 2011 6:36 am
by real-webjunky
sounds very good ;) have to check for this.

what about new teases in the minutes they have no rating at all?

Re: Script to Hide Poorly Rated Webteases

Posted: Tue Jul 05, 2011 8:57 am
by les

I for one wish independent verification'
That this is safe from some of our other programmers,
Before I implement it.

Re: Script to Hide Poorly Rated Webteases

Posted: Tue Jul 05, 2011 2:06 pm
by curved
I like it - works fine in Chrome. I know enough about javascript to know it isn't doing anything harmful but won't go as far as giving official verification...

Re: Script to Hide Poorly Rated Webteases

Posted: Tue Jul 05, 2011 4:34 pm
by Nooble
@les
I know a little Javascript, it doesn't look as though it's doing anything harmful. As 'curved' said, I also cannot provide official verification, but personally I wouldn't hesitate to use it.

My only issue would be on a moral level really. I'm not sure I trust users voting sensibilities or the voting system enough to warrant filtering out all poorly rated teases, although I too am annoyed by the prevalence of self-advertising teases lately.

Re: Script to Hide Poorly Rated Webteases

Posted: Tue Jul 05, 2011 6:08 pm
by g[mx]
real-webjunky wrote:what about new teases in the minutes they have no rating at all?
Didn't test that. My guess is it will be hidden with a rating of "0.0" - you'll have to click on the replacement text to display it.

The security concerns are absolutely valid, although the script doesn't anything bad, can't give you more than my word about that.

However the code shouldn't be that hard to understand by a decent javascript programmer: The script essentially asks the browser to be executed every time the tease list is changing (e.g. paging), it then processes all teases and hides those with a rating less than 2.5.

If you want to be more secure, take a look at the source when clicking on the installation link (or copy and install the code manually).

Re: Script to Hide Poorly Rated Webteases

Posted: Tue Jul 05, 2011 6:34 pm
by cumhardy
thanks for this! How do I use it in chrome?

Re: Script to Hide Poorly Rated Webteases

Posted: Mon Jul 25, 2011 6:56 pm
by janmb
les wrote:
I for one wish independent verification'
That this is safe from some of our other programmers,
Before I implement it.
Don't worry, it is clean

That's another nice thing about scripted languages - so much easier to see what it does and doesn't do.


Thanks for the script - I love it. One possible amendment to consider though, if at all possible, would be to always display favourite teases regardless of rank.