Created
October 12, 2010 12:56
-
-
Save vrld/622124 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @include *love2d.org/forums/viewtopic.php* | |
// ==/UserScript== | |
(function(){ | |
function getElementsByTagAndClass(tag, cls) { | |
var tags = document.getElementsByTagName(tag); | |
var ret = []; | |
for (var i = 0; i < tags.length; ++i) { | |
if (tags[i].className.indexOf(cls) > -1) | |
ret.push(tags[i]); | |
} | |
return ret; | |
} | |
// get own name | |
var logoutStr = getElementsByTagAndClass("li", "icon-logout")[0]; | |
var user = logoutStr.firstChild.title.replace(/^Logout \[\s+/, "").replace(/\s+\]$/, ""); | |
// get author list | |
var posts = getElementsByTagAndClass("div", "post "); | |
var authors = [] | |
for (var i = 0; i < posts.length; ++i) { | |
var author = posts[i].childNodes[1].childNodes[2].childNodes[5].childNodes[2].firstChild.innerHTML; // yeah, i know... | |
authors.push(author); | |
} | |
var beforebeforelast = authors[authors.length - 3]; | |
var beforelast = authors[authors.length - 2]; | |
var last = authors[authors.length - 1]; | |
function checkDoublePost() { | |
if (last == user) { | |
if (beforelast == user) { | |
if (beforebeforelast == user) { | |
alert("Quadruplepost?! NO!"); | |
return false; | |
} | |
return confirm("Triple post? Really?"); | |
} | |
return confirm("Are you sure you want to double post?\nYou can always edit your post."); | |
} | |
return true; | |
} | |
// add question popup to reply and quote links | |
var links = []; | |
var reply = getElementsByTagAndClass("div", "reply-icon"); | |
for (var i = 0; i < reply.length; ++i) | |
links.push(reply[i].firstChild); | |
var quote = getElementsByTagAndClass("li", "quote-icon"); | |
for (var i = 0; i < quote.length; ++i) | |
links.push(quote[i].firstChild); | |
for (var i = 0; i < links.length; ++i) | |
links[i].onclick = checkDoublePost; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment