Skip to content

Instantly share code, notes, and snippets.

@fabienhinault
Last active August 29, 2015 14:06
Show Gist options
  • Save fabienhinault/ca23f36b62394bb88dbd to your computer and use it in GitHub Desktop.
Save fabienhinault/ca23f36b62394bb88dbd to your computer and use it in GitHub Desktop.
les breves de l'esprit public
// ==UserScript==
// @name breves
// @namespace fhi
// @include http://www.franceculture.fr/emission-l-esprit-public*
// @version 1
// @grant none
// ==/UserScript==
function reqListener () {
var astrEmissions =
this.responseText.match(/<li class="first odd">[^]*<li class="last [^]*\n <\/li>/);
ul.innerHTML += astrEmissions[0];
}
var ul = document.querySelector("ul.list-article");
var pages = document.querySelectorAll("span.pager-item > a");
for( var iPage = 0; iPage < pages.length - 1; iPage++){
var page = pages[iPage];
var oReq = new XMLHttpRequest();
oReq.onload = reqListener;
oReq.open("get", page.href, true);
oReq.send();
}
function changeBreves () {
var nodes = document.querySelectorAll("ul.list-article>li>div>h2>a");
console.log(nodes);
console.log(nodes.length);
for( var iNode = 0; iNode < nodes.length; iNode++)
{
var node = nodes[iNode];
console.log(node);
var parent = node.parentNode;
console.log(parent);
var oReq = new XMLHttpRequest();
oReq.onload =
function(localParent){
return function(){
var next = localParent.nextSibling.nextSibling.querySelector("div>div>div>div");
astrBreves = this.responseText.match(/<p><strong>Brèves[^]*<ul class="links">/);
if(null != astrBreves){
var strBreves = astrBreves[0].match(/[^]*<\/p>/);
next.innerHTML = strBreves;
}
else{
next.innerHTML = "";
}
astrDocs = this.responseText.match(/<div class="rel-doc">[^]*<div id="block-print-0"/);
if(null != astrDocs){
var strDocs = astrDocs[0].match(/<ul>[^]*<\/ul>/);
next.innerHTML += strDocs;
}
}
}(parent);
oReq.open("get", node.href, true);
oReq.send();
}
}
setTimeout(changeBreves, 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment