Greasy Fork 还支持 简体中文。

ClonPost

Clonador de posts.

目前為 2016-01-27 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name ClonPost
  3. // @version 0.1
  4. // @description Clonador de posts.
  5. // @match http://www.poringa.net/agregar
  6. // @include *://*.poringa.net/agregar
  7. // @include *://*.poringa.net/agregar
  8. // @copyright @Cazador4ever
  9. // @namespace http://www.taringa.net/Cazador4ever
  10. // ==/UserScript==
  11. /* jshint -W097 */
  12. 'use strict';
  13.  
  14. (function() {
  15. 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>');
  16. $('#sidebar').prepend(crear)
  17. var htmlToBBCode = function(html) {
  18.  
  19. html = html.replace(/<pre(.*?)>(.*?)<\/pre>/gmi, "[code]$2[/code]");
  20.  
  21. html = html.replace(/<h[1-7](.*?)>(.*?)<\/h[1-7]>/, "\n[h]$2[/h]\n");
  22.  
  23. //paragraph handling:
  24. //- if a paragraph opens on the same line as another one closes, insert an extra blank line
  25. //- opening tag becomes two line breaks
  26. //- closing tags are just removed
  27. // html += html.replace(/<\/p><p/<\/p>\n<p/gi;
  28. // html += html.replace(/<p[^>]*>/\n\n/gi;
  29. // html += html.replace(/<\/p>//gi;
  30.  
  31. html = html.replace(/<br(.*?)>/gi, "\n");
  32. html = html.replace(/<textarea(.*?)>(.*?)<\/textarea>/gmi, "\[code]$2\[\/code]");
  33. html = html.replace(/<b>/gi, "[b]");
  34. html = html.replace(/<i>/gi, "[i]");
  35. html = html.replace(/<u>/gi, "[u]");
  36. html = html.replace(/<\/b>/gi, "[/b]");
  37. html = html.replace(/<\/i>/gi, "[/i]");
  38. html = html.replace(/<\/u>/gi, "[/u]");
  39. html = html.replace(/<em>/gi, "[b]");
  40. html = html.replace(/<\/em>/gi, "[/b]");
  41. html = html.replace(/<strong>/gi, "[b]");
  42. html = html.replace(/<\/strong>/gi, "[/b]");
  43. html = html.replace(/<cite>/gi, "[i]");
  44. html = html.replace(/<\/cite>/gi, "[/i]");
  45. html = html.replace(/<font color="(.*?)">(.*?)<\/font>/gmi, "[color=$1]$2[/color]");
  46. html = html.replace(/<font color=(.*?)>(.*?)<\/font>/gmi, "[color=$1]$2[/color]");
  47. html = html.replace(/<link(.*?)>/gi, "");
  48. html = html.replace(/<li(.*?)>(.*?)<\/li>/gi, "[*]$2");
  49. html = html.replace(/<ul(.*?)>/gi, "[list]");
  50. html = html.replace(/<\/ul>/gi, "[/list]");
  51. html = html.replace(/<div>/gi, "\n");
  52. html = html.replace(/<\/div>/gi, "\n");
  53. html = html.replace(/<td(.*?)>/gi, " ");
  54. html = html.replace(/<tr(.*?)>/gi, "\n");
  55.  
  56. html = html.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, "[img]$2[/img]");
  57. html = html.replace(/<a(.*?)href="(.*?)"(.*?)>(.*?)<\/a>/gi, "[url=$2]$4[/url]");
  58.  
  59. html = html.replace(/<head>(.*?)<\/head>/gmi, "");
  60. html = html.replace(/<object>(.*?)<\/object>/gmi, "");
  61. html = html.replace(/<script(.*?)>(.*?)<\/script>/gmi, "");
  62. html = html.replace(/<style(.*?)>(.*?)<\/style>/gmi, "");
  63. html = html.replace(/<title>(.*?)<\/title>/gmi, "");
  64. html = html.replace(/<!--(.*?)-->/gmi, "\n");
  65.  
  66. html = html.replace(/\/\//gi, "/");
  67. html = html.replace(/http:\//gi, "http://");
  68.  
  69. html = html.replace(/<(?:[^>'"]*|(['"]).*?\1)*>/gmi, "");
  70. html = html.replace(/\r\r/gi, "");
  71. html = html.replace(/\[img]\//gi, "[img]");
  72. html = html.replace(/\[url=\//gi, "[url=");
  73.  
  74. html = html.replace(/(\S)\n/gi, "$1 ");
  75.  
  76. return html;
  77. }
  78. function rss() {
  79. var id = $('#PostId').val ();
  80. var api = 'http://api.taringa.net/post/view/' + id
  81. $.getJSON( api, function(json) {
  82. var body= $('#markItUp').val();
  83. var a = $('#markItUp');
  84. var titulo = $('#titulo-input');
  85. var tit = json.title;
  86. var d = json.images[0].body;
  87. var link = json.query.results.item[0].link;
  88. var c = htmlToBBCode(''+d+''+link+'');
  89. a.val(body+c).click().focus();
  90. titulo.val(tit).click().focus();});
  91. } go.onclick=rss;
  92. })();