// ==UserScript== // @name [Erepublik] Extract BBCode of articles // @match *://www.erepublik.com/en/article/* // @version 0.1 // @description Extracts BBCode of articles // @author Mike Ontry // @grant none // @namespace https://greasyfork.org/users/3941 // @downloadURL none // ==/UserScript== var main = jQuery(document).find('div[class="post_content"]').get(0); jQuery(main).find('h2').before('Extract BBCode'); jQuery(document).find('a[id="extractBB"]').on("click", function() { var content = jQuery(main).find('div[class="full_content"]').html(); jQuery(document).find('div[class="holder"]').after(''); location.hash = "bbCodeCont"; }); function HtmltoBB(html) { html = html.replace(//gi, "\n\r"); html = html.replace(//gi, "[b]"); html = html.replace(//gi, "[i]"); html = html.replace(//gi, "[u]"); html = html.replace(/<\/b>/gi, "[/b]"); html = html.replace(/<\/i>/gi, "[/i]"); html = html.replace(/<\/u>/gi, "[/u]"); html = html.replace(//gi, "[b]"); html = html.replace(/<\/em>/gi, "[/b]"); html = html.replace(//gi, "[b]"); html = html.replace(/<\/strong>/gi, "[/b]"); html = html.replace(//gi, "[s]"); html = html.replace(/<\/strike>/gi, "[/s]"); html = html.replace(//gi, "[sub]"); html = html.replace(/<\/sub>/gi, "[/sub]"); html = html.replace(//gi, "[sup]"); html = html.replace(/<\/sup>/gi, "[/sup]"); html = html.replace(/
/gi, "-----"); //html = html.replace(/([\s\S]*?)<\/div>?=*$/gmi, "[$2]$4[/$2]"); html = html.replace(//gi, "[center]"); html = html.replace(/<\/div>/gi, "[/center]"); html = html.replace(//gi, "[img]$2[/img]"); html = html.replace(/(.*?)<\/a>/gi, "[url=$2]$4[/url]"); html = html.replace(/\/\//gi, "/"); html = html.replace(/http:\//gi, "http://"); html = html.replace(/<(?:[^>'"]*|(['"]).*?\1)*>/gmi, ""); html = html.replace(/\r\r/gi, ""); html = html.replace(/\[img]\//gi, "[img]"); html = html.replace(/\[url=\//gi, "[url="); html = html.replace(/(\S)\n/gi, "$1 "); return html; }