Skip to content

Instantly share code, notes, and snippets.

@zthomae
Created April 27, 2012 03:27
Show Gist options
  • Select an option

  • Save zthomae/2505536 to your computer and use it in GitHub Desktop.

Select an option

Save zthomae/2505536 to your computer and use it in GitHub Desktop.
Userscript to link headlines on madison.com blogs
// ==UserScript==
// @name "On Campus" linker
// @namespace http://twitter.com/zthomae
// @description Adds links to madison.com blog posts
// @include http://host.madison.com/wsj/local/education/on_campus/
// @include
// @include http://host.madison.com/wsj/local/education/extra-credit/
// @include http://host.madison.com/lifestyles/faith-and-values/religion/
// @include http://host.madison.com/wsj/business/technology/biotech/
// @include http://host.madison.com/ct/local/crime_and_courts/blog/
// @include http://host.madison.com/ct/local/madison_360/
// @include http://host.madison.com/ct/local/govt_and_politics/politiscope/
// @include http://host.madison.com/ct/local/education/campus_connection/
// @include http://host.madison.com/ct/local/govt_and_politics/blog/
// @include http://host.madison.com/ct/local/grassroots/
// @include http://host.madison.com/ct/local/govt_and_politics/city_hall/
// @include http://host.madison.com/ct/business/biz_beat/
// @require http://code.jquery.com/jquery-latest.min.js
// @version 0.3
// ==/UserScript==
function getXML() {
$.ajax({
type: "GET",
//url: "http://host.madison.com/search/?f=rss&t=article&l=25&s=start_time&sd=desc&c=news/local/education/on_campus*&q=%23wsj",
url: "http://host.madison.com" + $('.rss').attr('href'),
datatype: "xml",
complete: function(data) {
fixLinks(data);
}
});
}
function fixLinks(data) {
$('div').find('.story-block').find('h3').each(function(index){
$(this).wrap('<a href="' + $(data.responseXML).find('item link').get(index).textContent + '" />' )});
}
getXML();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment