HIP Extended

Script permettant l'enrichissement du catalogue de la Médiathèque de Saint-Nazaire (HIP4+)

  1. // ==UserScript==
  2. // @name HIP Extended
  3. // @author Antoine Verney (@lebartok)
  4. // @grant GM_xmlhttpRequest
  5. // @grant GM_getValue
  6. // @namespace https://mediatheque.mairie-saintnazaire.fr/
  7. // @description Script permettant l'enrichissement du catalogue de la Médiathèque de Saint-Nazaire (HIP4+)
  8. // @include https://mediatheque.mairie-saintnazaire.fr/*
  9. // @version 0.0.1.20190704163427
  10. // ==/UserScript==
  11.  
  12. /*
  13. Note : ce script est largement inspiré de "Sudoc plus" (http://userscripts-mirror.org/scripts/review/60741) réalisé par Sylvain Machefert (@symac)
  14. */
  15.  
  16. permalink();
  17. notice_plus();
  18.  
  19. //----------------------------------------------------------
  20. // Ajout d'un permalien + boutons de partage
  21. //----------------------------------------------------------
  22. function permalink() {
  23. var link = document.getElementsByTagName("input")[64].value;
  24. link = link.replace(" ", "");
  25. link = link.replace(new RegExp(".awdid=.","i"), '');
  26. link = link.replace(new RegExp("[a-z]+","g"), '');
  27. var full_link = 'https://mediatheque.mairie-saintnazaire.fr/uPortal/Initialize?uP_reload_layout=true&uP_tparam=props&uP_sparam=activeTab&activeTab=2&showBrief=true&link=full' + link + '&currentPosition=0&searchTargetId=16';
  28. if ((link != "<Péé")&&(link != "")&&(link != "MOTSCLES")) {
  29. // Affichage Permalien
  30. newtd = document.createElement("td");
  31. newtd.id = 'permalien';
  32. newtd.innerHTML = '&nbsp;&nbsp;<img src="https://antoinev.alwaysdata.net/link.png"/> <a target="_blank" href="' +full_link+'">Permalien</a><br /><br />';
  33. document.getElementsByTagName("table")[19].appendChild(newtd);
  34. }
  35. }
  36.  
  37. //----------------------------------------------------------
  38. // Enrichissement des notices bib (couverture, renvois)
  39. //----------------------------------------------------------
  40. function notice_plus() {
  41. var serveur='https://antoinev.alwaysdata.net/cover.php?action=couv&isbn=';
  42. var isbn = document.getElementsByTagName("table")[21].rows[3].cells[1].textContent;
  43. isbn = isbn.replace(new RegExp("[^(0-9X)]", "g"), '');
  44. isbn = isbn.replace("()", "");
  45. GM_xmlhttpRequest({
  46. method: 'GET',
  47. url: serveur+isbn,
  48. onload: function(responseDetails) {
  49. if (responseDetails.responseText != "") {
  50. var cover = responseDetails.responseText;
  51. // Affichage de la couverture Amazon
  52. if (cover != "") {
  53. newtd = document.createElement("td");
  54. newtd.id = 'couv';
  55. newtd.style.padding = '0px 70px 0px 30px';
  56. newtd.style.font = 'large';
  57. newtd.innerHTML = '<center><br /><br /><img border="0" style="box-shadow: 0.5px 0.5px 1px 0.5px;" src="' + cover + '"/><br/><p style="padding-top:2px; margin:0; font-size:0.7em;">source: <a target="_blank" href="https://www.amazon.fr">Amazon</a></p></center>';
  58. document.getElementsByTagName("table")[19].rows[0].appendChild(newtd);
  59. }
  60. // Affichage des renvois Google livres, Librarything, Sudoc
  61. newtd = document.createElement("td");
  62. newtd.id = 'renvois';
  63. newtd.innerHTML = '<br /><p>&nbsp;&nbsp;Rechercher ce document sur : <a target="_blank" href="https://www.sudoc.abes.fr/DB=2.1/CMD?ACT=SRCHA&IKT=7&SRT=RLV&TRM=' + isbn + '"><img border="0" align="absmiddle" src="https://antoinev.alwaysdata.net//logo_sudoc.png"/></a>&nbsp;&nbsp;<a target="_blank" href="https://books.google.com/books?vid=ISBN' + isbn + '"><img border="0" align="texttop" src="https://antoinev.alwaysdata.net//logo_books.png"/></a></p>';
  64. document.getElementsByTagName("table")[20].appendChild(newtd);
  65. }
  66. }
  67. });
  68. }
  69.  
  70. //----------------------------------------------------------
  71. // Gestion des versions du script
  72. //----------------------------------------------------------
  73. // var SUC_script_num = 94622; // Change this to the number given to the script by userscripts.org (check the address bar)
  74. // try{function updateCheck(forced){if ((forced) || (parseInt(GM_getValue('SUC_last_update', '0')) + 86400000 <= (new Date().getTime()))){try{GM_xmlhttpRequest({method: 'GET',url: 'http://userscripts.org/scripts/source/'+SUC_script_num+'.meta.js?'+new Date().getTime(),headers: {'Cache-Control': 'no-cache'},onload: function(resp){var local_version, remote_version, rt, script_name;rt=resp.responseText;GM_setValue('SUC_last_update', new Date().getTime()+'');remote_version=parseInt(/@uso:version\s*(.*?)\s*$/m.exec(rt)[1]);local_version=parseInt(GM_getValue('SUC_current_version', '-1'));if(local_version!=-1){script_name = (/@name\s*(.*?)\s*$/m.exec(rt))[1];GM_setValue('SUC_target_script_name', script_name);if (remote_version > local_version){if(confirm('Une nouvelle version du script "'+script_name+'." est disponible\nVoulez-vous l\'installer maintenant (conseillé) ?')){GM_openInTab('http://userscripts.org/scripts/show/'+SUC_script_num);GM_setValue('SUC_current_version', remote_version);}}else if (forced)alert('No update is available for "'+script_name+'."');}else GM_setValue('SUC_current_version', remote_version+'');}});}catch (err){if (forced)alert('An error occurred while checking for updates:\n'+err);}}}GM_registerMenuCommand(GM_getValue('SUC_target_script_name', '???') + ' - Manual Update Check', function(){updateCheck(true);});updateCheck(false);}catch(err){}
  75.  
  76. updateCheck(0);