bgm-wiki-rev-diff

show diff between bgm.tv wiki versions

Stan na 19-07-2020. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         bgm-wiki-rev-diff
// @namespace    https://trim21.me/
// @version      0.0.9
// @author       Trim21 <[email protected]>
// @source       https://github.com/Trim21/bgm-wiki-rev-diff
// @supportURL   https://github.com/Trim21/bgm-wiki-rev-diff/issues
// @license      MIT
// @match        https://bgm.tv/subject/*/edit
// @match        https://bangumi.tv/subject/*/edit
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/bundles/js/diff2html.min.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/diff.min.js
// @grant        GM_xmlhttpRequest
// @connect      bgm.tv
// @connect      bangumi.tv
// @run-at       document-end
// @description show diff between bgm.tv wiki versions
// ==/UserScript==

!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="e6Wu")}({HIjm:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.compare=void 0;const r=n("MI+m"),o=n("j7bY"),i=n("epE4"),s=n("Va9c"),c=n("kvtW");t.compare=function(e,t){s.clear(),s.show("<h2>loading versions...</h2>");const n=r.getRevInfo(e),l=r.getRevInfo(t),u=o.request(n.url),a=o.request(l.url);Promise.all([u,a]).then(e=>{const t=[];for(const n of e)t.push(r.parseRevDetails(n.responseText));const o=new c.Comment(n,t[0]),u=new c.Comment(l,t[1]),a=i.diff(o,u),f=s.render(a);s.show(f)}).catch(()=>{s.show('<h2 style="color:red">loading versions error</h2>')})}},"MI+m":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRevInfo=t.parseRevEl=t.parseRevDetails=void 0;const r=n("xeH2"),o=n("kvtW");function i(e){const t=e.find("a").first().html(),n=e.find('a.l:contains("恢复")'),r=e.find("span.comment");let o="";r.length&&(o=r.html(),o=o.substring(1,o.length-1));const i=n.attr("href");return{id:i.split("/").pop(),comment:o,date:t,url:i}}t.parseRevDetails=function(e){const t=r(e),n=t.find("#subject_infobox").val().toString(),i=t.find('input[name="subject_title"]').val().toString(),s=t.find("textarea#subject_summary").val().toString();return new o.RevDetail(i,n,s)},t.parseRevEl=i,t.getRevInfo=function(e){for(const t of function(){const e=[];return r("#pagehistory li").each((function(){const t=r(this);try{e.push(i(t))}catch(e){}})),e}())if(t.id===e)return t}},O5RH:function(e,t){e.exports=Diff},Va9c:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clear=t.show=t.render=void 0;const r=n("znBf"),o=n("xeH2");t.render=function(e){return r.html(e)},t.show=function(e){o("#show-trim21-cn").html(e)},t.clear=function(){o("#show-trim21-cn").html("")}},e6Wu:function(e,t,n){"use strict";n.r(t);var r=n("xeH2"),o=n("MI+m"),i=n("HIjm");console.log("start bgm wiki rev differ UserScript"),r("#columnInSubjectA").prepend("<div id=show-trim21-cn></dev>"),r("#pagehistory li").each((function(){const e=r(this);try{const t=Object(o.parseRevEl)(e);e.prepend(`<input type="checkbox" class="rev-trim21-cn" name="rev" label="select to compare" value="${t.id}">`)}catch(e){}})),r("#columnInSubjectA span.text").append('<a href="#;" id="compare-trim21-cn" tar class="l"> > 比较选中的版本</a>'),r("#compare-trim21-cn").on("click",(function(){const e=function(){const e=[],t=r(".rev-trim21-cn:checked");return t.length<2&&window.alert("请选中两个版本进行比较"),t.length>2&&window.alert("只能比较两个版本"),t.each((function(){const t=r(this);e.push(t.val())})),e.reverse(),e}();Object(i.compare)(e[0],e[1])})),r("head").append('<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/diff2html/bundles/css/diff2html.min.css" />')},epE4:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;const r=n("O5RH");t.diff=function(e,t){return`${function(e,t){if(e.details.title===t.details.title)return"";return r.createTwoFilesPatch("title","title",e.details.title,t.details.title,e.rev.date,t.rev.date)}(e,t)}\n${function(e,t){if(e.details.rawInfo===t.details.rawInfo)return"";return r.createTwoFilesPatch("info","info",e.details.rawInfo,t.details.rawInfo,e.rev.date,t.rev.date)}(e,t)}\n${function(e,t){if(e.details.description===t.details.description)return"";return r.createTwoFilesPatch("description","description",e.details.description,t.details.description,e.rev.date,t.rev.date)}(e,t)}`}},j7bY:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0,t.request=function(e){return new Promise(t=>{window.GM_xmlhttpRequest({url:e,onload:function({responseText:e}){t({responseText:e})}})})}},kvtW:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Comment=t.Rev=t.RevDetail=void 0;t.RevDetail=class{constructor(e,t,n){this.title=e,this.rawInfo=t,this.description=n}};t.Rev=class{};t.Comment=class{constructor(e,t){this.rev=e,this.details=t}}},xeH2:function(e,t){e.exports=$},znBf:function(e,t){e.exports=Diff2Html}});