| |
![]() | |
![]() |
| | Thread Tools |
| | #1 (permalink) |
| New Member Join Date: Oct 2006 Location: Germany
Posts: 40
![]() | Firefox and Greasemonkey: Opening new threads Hi all, Since I am a lazy bum and like my machine to do things for me, I came up with a little script which allows me to have all new threads opened in new windows/tabs, and I'd like to share that here - but let me explain: The Mozilla family of browsers (Firefox and Seamonkey) can be enhanced with an extension called Greasemonkey (link -->) Greasespot which allows you to do a bunch of fancy things. These things are done by installing scripts, which have been written by other people, or yourself. I found myself quite often hitting the "New Posts" menu link and then go through all those threads with new entries, hitting each of those pesky little icons with a middle mouse click, so opening it in a new tab of my Firefox browser. This is tedious. ![]() If you download and install Greasemonkey from the above link, you can then install the attached script by either copying it into the directory where your scripts reside (using the Greasemonkey script naming convention, name.user.js - and then enabling the script in the "manage user scripts" menu), or by "adding a new script" and simply copy/pasting the script into the editor. If all goes well, it is supposed to create a new link at the top of the new post search results page (cleverly called "Open all new threads in new Windows") - and once you click it, all new threads on this page are each opened in a new window/tab, depending on your FF-settings. Here it seems to do its job nicely, but I'd be very interested in how it works for others. HTH, enjoy, greets, tobi... ![]() Code: // ==UserScript==
// @name Dir Explorers: Open new threads
// @namespace http://tobihofmann.de/
// @description Opens all those new threads in a new window/tab each
// @include http://www.direxplorers.com/search.php?searchid=*
// @include http://*.direxplorers.com/search.php?searchid=*
// ==/UserScript==
function embedFunction(s) {
document.body.appendChild(document.createElement('script')).innerHTML=s.toString().replace(/([\s\S]*?return;){2}([\s\S]*)}/,'$2');
}
function openallnewthreadsDirX() {
var allLinks, thisLink;
allLinks = document.evaluate(
"//a[starts-with(@id,'thread_gotonew')]",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
// do something with thisLink
window.open(thisLink);
}
}
embedFunction(openallnewthreadsDirX);
// add banner with download link
var my_banner = document.createElement("div");
my_banner.innerHTML = '<div style="border-bottom: 1px solid #CCCCCC; margin-bottom: 10px; font-size: small; background-color: #FF0000; color: #FFFFFF;">' +
'<p style="margin:0px;padding: 5px;text-align:center;">' +
'<a href="javascript:openallnewthreadsDirX()" style="color:#FFFFFF; font-weight:bold; font-size:10px;">Open all new threads in new Windows</a>' +
'</p></div>';
document.body.insertBefore(my_banner, document.body.firstChild); |
|