- // ==UserScript==
- // @name ClonPost
- // @version 0.1
- // @description Clonador de posts.
- // @match http://www.poringa.net/agregar
- // @include *://*.poringa.net/agregar
- // @include *://*.poringa.net/agregar
- // @copyright @Cazador4ever
- // @namespace http://www.taringa.net/Cazador4ever
- // ==/UserScript==
- /* jshint -W097 */
- 'use strict';
-
- (function() {
- var crear = $('<center><textarea id="PostId" class="user-text" tabindex="700" placeholder="#PostId" autocomplete="on" style="width:100px; height: 15px; background: rgb(255, 255, 255);resize: none; "></textarea><div class="box box-solid bg-black" style="width:100%; background-color:#FFFFF"><a class="btn g go" href="#" id="go"><div class="btn-text">Clonar</div></a></div></div></center>');
- $('#sidebar').prepend(crear)
-
- var htmlToBBCode = function(html) {
-
- html = html.replace(/<pre(.*?)>(.*?)<\/pre>/gmi, "[code]$2[/code]");
-
- html = html.replace(/<h[1-7](.*?)>(.*?)<\/h[1-7]>/, "\n[h]$2[/h]\n");
-
- //paragraph handling:
- //- if a paragraph opens on the same line as another one closes, insert an extra blank line
- //- opening tag becomes two line breaks
- //- closing tags are just removed
- // html += html.replace(/<\/p><p/<\/p>\n<p/gi;
- // html += html.replace(/<p[^>]*>/\n\n/gi;
- // html += html.replace(/<\/p>//gi;
-
- html = html.replace(/<br(.*?)>/gi, "\n");
- html = html.replace(/<textarea(.*?)>(.*?)<\/textarea>/gmi, "\[code]$2\[\/code]");
- html = html.replace(/<b>/gi, "[b]");
- html = html.replace(/<i>/gi, "[i]");
- html = html.replace(/<u>/gi, "[u]");
- html = html.replace(/<\/b>/gi, "[/b]");
- html = html.replace(/<\/i>/gi, "[/i]");
- html = html.replace(/<\/u>/gi, "[/u]");
- html = html.replace(/<em>/gi, "[b]");
- html = html.replace(/<\/em>/gi, "[/b]");
- html = html.replace(/<strong>/gi, "[b]");
- html = html.replace(/<\/strong>/gi, "[/b]");
- html = html.replace(/<cite>/gi, "[i]");
- html = html.replace(/<\/cite>/gi, "[/i]");
- html = html.replace(/<font color="(.*?)">(.*?)<\/font>/gmi, "[color=$1]$2[/color]");
- html = html.replace(/<font color=(.*?)>(.*?)<\/font>/gmi, "[color=$1]$2[/color]");
- html = html.replace(/<link(.*?)>/gi, "");
- html = html.replace(/<li(.*?)>(.*?)<\/li>/gi, "[*]$2");
- html = html.replace(/<ul(.*?)>/gi, "[list]");
- html = html.replace(/<\/ul>/gi, "[/list]");
- html = html.replace(/<div>/gi, "\n");
- html = html.replace(/<\/div>/gi, "\n");
- html = html.replace(/<td(.*?)>/gi, " ");
- html = html.replace(/<tr(.*?)>/gi, "\n");
-
- html = html.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, "[img]$2[/img]");
- html = html.replace(/<a(.*?)href="(.*?)"(.*?)>(.*?)<\/a>/gi, "[url=$2]$4[/url]");
-
- html = html.replace(/<head>(.*?)<\/head>/gmi, "");
- html = html.replace(/<object>(.*?)<\/object>/gmi, "");
- html = html.replace(/<script(.*?)>(.*?)<\/script>/gmi, "");
- html = html.replace(/<style(.*?)>(.*?)<\/style>/gmi, "");
- html = html.replace(/<title>(.*?)<\/title>/gmi, "");
- html = html.replace(/<!--(.*?)-->/gmi, "\n");
-
- 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;
- }
-
- function rss() {
- var id = $('#PostId').val ();
- var api = 'http://api.taringa.net/post/view/' + id
- $.getJSON( api, function(json) {
- var body= $('#markItUp').val();
- var a = $('#markItUp');
- var titulo = $('#titulo-input');
- var tit = json.title;
- var d = json.images[0].body;
- var link = json.query.results.item[0].link;
- var c = htmlToBBCode(''+d+''+link+'');
- a.val(body+c).click().focus();
- titulo.val(tit).click().focus();});
- } go.onclick=rss;
-
- })();