source: other-projects/bib-stinky/trunk/nodejs-server/public/doi-stinky.user.js@ 36322

Last change on this file since 36322 was 36322, checked in by davidb, 21 months ago

More presentable layout

File size: 2.4 KB
Line 
1// ==UserScript==
2// @name Bib Stinky
3// @namespace http://bibstinky.sowemustthink.space/
4// @version 0.1
5// @description Helps identify when metadata stored by a publication provider or agregator might be a bit 'off'
6// @author David Bainbridge
7// @author Dave Nichols
8// @author Mike Twidale
9// @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
10// @match https://www.cs.waikato.ac.nz/*
11// @match https://search.crossref.org/*
12// @grant GM_xmlhttpRequest
13// @connect bibstinky.sowemustthink.space
14// @connect bib-stinky.so-we-must-think.space
15// ==/UserScript==
16
17//alert("foo");
18
19(function() {
20 'use strict';
21
22 var $ = window.jQuery;
23
24 var doi_list = [];
25 var doi_pattern = /^http(?:s)?:\/\/doi.org\/(.*)$/i;
26
27 $('a').each(function() {
28 var href=$(this).attr('href');
29 var doi_pattern_matches = doi_pattern.exec(href);
30 if (doi_pattern_matches != null) {
31 var doi_id = doi_pattern_matches[1];
32 doi_list.push(doi_id);
33 }
34 });
35
36 // console.log(doi_list);
37
38 var elmWrapperDiv = document.createElement('div');
39 elmWrapperDiv.id = "doiStinkyBar";
40
41 $(document).ready(function() {
42 //console.log("Adding in <div> to display DOI Stinky bar at top:");
43 elmWrapperDiv.style.width = '100%';
44 //elmWrapperDiv.style.textAlign = 'center';
45 elmWrapperDiv.style.fontFamily = 'sans-serif';
46 elmWrapperDiv.style.backgroundColor = 'wheat';
47
48 elmWrapperDiv.style.zIndex = '25';
49 elmWrapperDiv.style.position = 'fixed';
50
51 document.body.insertBefore(elmWrapperDiv, document.body.firstChild);
52
53 GM_xmlhttpRequest ( {
54 method: 'GET',
55 url: 'https://bibstinky.sowemustthink.space/doi-stinky-bar.html',
56 onload: function (responseDetails) {
57
58 var returned_html_str = responseDetails.responseText;
59 var body_str = returned_html_str.substring(returned_html_str.indexOf("<body>")+6,returned_html_str.indexOf("</body>"))
60 //console.log("returned body = " + body_str.substring (0) + '...');
61
62 var body = $.parseHTML(body_str);
63 $("#doiStinkyBar").append(body);
64
65 if (doi_list.length > 0) {
66 $('#doiStinkyInfo').append(doi_list.join(","));
67 }
68 else {
69 $('#doiStinkyInfo').append("No DOIs detected on the page");
70 }
71 }
72 } );
73});
74
75})();
Note: See TracBrowser for help on using the repository browser.