/** * Parse GDPR text * @author Harshvardhan Pandit me a.t. harshp.com * @name parse_gdpr * LICENSE: MIT * * This script parses GDPR text from the webpage into a JSON document * It also re-arranges the text into a better version where each individual * item in the text is assigned a contextual ID attribute making it * easy to reference the particular item. */ var FLG_DEBUG = true; if (!FLG_DEBUG) { console.log = function() {}; } /** * @return {jQuery array} returns all GDPR article text */ var extract_gdpr_articles_from_page = function() { // starting element is the one just before CHAPTER I var begin = $('p#d1e1374-1-1').prev(); // ending element is the div marked final var end = $('div.final'); // first processing element is the one after begin (CHAPTER I) var element = begin.next(); var text = []; // continue while we haven't reached the end element while (!element.is(end)) { text.push(element); element = element.next(); } return text; } var txt_gdpr = extract_gdpr_articles_from_page(); /** * @param {jQuery array} text contains the text of the GDPR * @return {[array of arrays]} chapters extracted from text * Each chapter contains the sections and articles within it sequentially * in the arrays inside it * [chapters] where [chapter] contains everything as jQuery array */ var extract_chapters_from_gdpr_text = function(text) { var chapters = []; var chapter = null; var chapter_contents = null; for (var i=0; i').appendTo('body'); var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(data)); var btn_download = document.getElementById('downloadAnchorElem'); btn_download.setAttribute("href", dataStr); btn_download.setAttribute("download", "gdpr.json"); /** TO DOWNLOAD, CALL THIS IN BROWSER CONSOLE **/ // btn_download.click();