There are 2 previous versions of this script.
// ==UserScript==
// @name Create scriptwriter feed
// @namespace http://whateveryouwant/
// @description Create userscripts author feed via special YPipe + AppJet app
// @include http://userscripts.org/users/*
// ==/UserScript==
/* Change log:
* version 0.1:
+ Released in userscripts.org
* version 0.2
+ Script runs now also on the "scripts" and "script comments" pages
- Fix bug when detecting user's nick (don't use the word 'name' for a global variable,
this is is the same as window.name and it is persisted across pages and windows!)
*/
const FONT = XPathResult.FIRST_ORDERED_NODE_TYPE;
const FEEDAPP = 'http://userscripts-by-author.appjet.net/';
const BASICFEED = FEEDAPP + 'feed';
const FULLFEED = FEEDAPP + 'fullfeed';
var xpath, username,
path = document.location.pathname,
user = path.replace(/^\/users\/(\d+).*/,"$1");
switch (path) {
case "/users/" + user :
xpath = '//h4[1]/text()'; // User's profile page
break;
case "/users/" + user + "/scripts" : // List of scripts by this user
/* cascade */ ;
case "/users/" + user + "/comments" : // List of comments by this user on other's scripts
/* cascade */ ;
case "/users/" + user + "/script_comments" : // List of comments to scripts of this user by other people
xpath = '//div[@id="content"]/h1/a/text()';
break;
default : xpath = null;
}
if (xpath) {
try {
var username = document.evaluate(xpath, document, null, FONT, null).singleNodeValue.nodeValue;
} catch (e){ /* should not happen, it does not hurt anyway */}
}
if(user){
// Basic feed: only listed scripts
var feedurl = BASICFEED + '?user=' + user + (username?'&name='+username:'');
var link = document.createElement('link');
link.setAttribute('href', feedurl);
link.setAttribute('rel', 'alternate');
link.setAttribute('title', 'Listed scripts by ' + (username?username:'this author'));
link.setAttribute('type', 'application/rss+xml' );
document.getElementsByTagName('head')[0].appendChild(link);
// Full feed: unlisted scripts as well
feedurl = FULLFEED + '?user=' + user + (username?'&name='+username:'');
link = document.createElement('link');
link.setAttribute('href', feedurl);
link.setAttribute('rel', 'alternate');
link.setAttribute('title', 'All scripts by ' + (username?username:'this author'));
link.setAttribute('type', 'application/rss+xml' );
document.getElementsByTagName('head')[0].appendChild(link);
}
