Greasy Fork is available in English.

Htm-preact

Htm-preact bundled

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.greasyfork.org/scripts/396835/775090/Htm-preact.js

// ==UserScript==
// @name         Htm-preact
// @namespace    eisen-stein
// @version      1.0.0
// @description  Htm-preact bundled
// ==/UserScript==

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["htm/preact"]=t():e["htm/preact"]=t()}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},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=0)}([function(e,t,n){"use strict";n.r(t);var o,r,l,u,_={},i=[],s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function p(e,t){for(var n in t)e[n]=t[n];return e}function c(e){var t=e.parentNode;t&&t.removeChild(e)}function f(e,t,n){var o,r=arguments,l={};for(o in t)"key"!==o&&"ref"!==o&&(l[o]=t[o]);if(arguments.length>3)for(n=[n],o=3;o<arguments.length;o++)n.push(r[o]);if(null!=n&&(l.children=n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===l[o]&&(l[o]=e.defaultProps[o]);return a(e,l,t&&t.key,t&&t.ref)}function a(e,t,n,r){var l={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:null,__c:null,constructor:void 0};return o.vnode&&o.vnode(l),l}function d(e){return e.children}function h(e,t){this.props=e,this.context=t}function y(e,t){if(null==t)return e.__?y(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?y(e):null}function v(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return v(e)}}function m(e){(!e.__d&&(e.__d=!0)&&1===r.push(e)||u!==o.debounceRendering)&&((u=o.debounceRendering)||l)(g)}function g(){var e,t,n,o,l,u,_;for(r.sort((function(e,t){return t.__v.__b-e.__v.__b}));e=r.pop();)e.__d&&(n=void 0,o=void 0,u=(l=(t=e).__v).__e,(_=t.__P)&&(n=[],o=P(_,l,p({},l),t.__n,void 0!==_.ownerSVGElement,null,n,null==u?y(l):u),C(n,l),o!=u&&v(l)))}function b(e,t,n,o,r,l,u,s,p){var f,a,d,h,v,m,g,b=n&&n.__k||i,x=b.length;if(s==_&&(s=null!=l?l[0]:x?y(n,0):null),f=0,t.__k=k(t.__k,(function(n){if(null!=n){if(n.__=t,n.__b=t.__b+1,null===(d=b[f])||d&&n.key==d.key&&n.type===d.type)b[f]=void 0;else for(a=0;a<x;a++){if((d=b[a])&&n.key==d.key&&n.type===d.type){b[a]=void 0;break}d=null}if(h=P(e,n,d=d||_,o,r,l,u,s,p),(a=n.ref)&&d.ref!=a&&(g||(g=[]),d.ref&&g.push(d.ref,null,n),g.push(a,n.__c||h,n)),null!=h){if(null==m&&(m=h),null!=n.__d)h=n.__d,n.__d=null;else if(l==d||h!=s||null==h.parentNode){e:if(null==s||s.parentNode!==e)e.appendChild(h);else{for(v=s,a=0;(v=v.nextSibling)&&a<x;a+=2)if(v==h)break e;e.insertBefore(h,s)}"option"==t.type&&(e.value="")}s=h.nextSibling,"function"==typeof t.type&&(t.__d=h)}}return f++,n})),t.__e=m,null!=l&&"function"!=typeof t.type)for(f=l.length;f--;)null!=l[f]&&c(l[f]);for(f=x;f--;)null!=b[f]&&D(b[f],b[f]);if(g)for(f=0;f<g.length;f++)j(g[f],g[++f],g[++f])}function k(e,t,n){if(null==n&&(n=[]),null==e||"boolean"==typeof e)t&&n.push(t(null));else if(Array.isArray(e))for(var o=0;o<e.length;o++)k(e[o],t,n);else n.push(t?t("string"==typeof e||"number"==typeof e?a(null,e,null,null):null!=e.__e||null!=e.__c?a(e.type,e.props,e.key,null):e):e);return n}function x(e,t,n){"-"===t[0]?e.setProperty(t,n):e[t]="number"==typeof n&&!1===s.test(t)?n+"px":null==n?"":n}function w(e,t,n,o,r){var l,u,_,i,s;if(r?"className"===t&&(t="class"):"class"===t&&(t="className"),"key"===t||"children"===t);else if("style"===t)if(l=e.style,"string"==typeof n)l.cssText=n;else{if("string"==typeof o&&(l.cssText="",o=null),o)for(u in o)n&&u in n||x(l,u,"");if(n)for(_ in n)o&&n[_]===o[_]||x(l,_,n[_])}else"o"===t[0]&&"n"===t[1]?(i=t!==(t=t.replace(/Capture$/,"")),s=t.toLowerCase(),t=(s in e?s:t).slice(2),n?(o||e.addEventListener(t,S,i),(e.l||(e.l={}))[t]=n):e.removeEventListener(t,S,i)):"list"!==t&&"tagName"!==t&&"form"!==t&&"type"!==t&&!r&&t in e?e[t]=null==n?"":n:"function"!=typeof n&&"dangerouslySetInnerHTML"!==t&&(t!==(t=t.replace(/^xlink:?/,""))?null==n||!1===n?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),n):null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,n))}function S(e){this.l[e.type](o.event?o.event(e):e)}function P(e,t,n,r,l,u,_,i,s){var c,f,a,y,v,m,g,x,w,S,P=t.type;if(void 0!==t.constructor)return null;(c=o.__b)&&c(t);try{e:if("function"==typeof P){if(x=t.props,w=(c=P.contextType)&&r[c.__c],S=c?w?w.props.value:c.__:r,n.__c?g=(f=t.__c=n.__c).__=f.__E:("prototype"in P&&P.prototype.render?t.__c=f=new P(x,S):(t.__c=f=new h(x,S),f.constructor=P,f.render=N),w&&w.sub(f),f.props=x,f.state||(f.state={}),f.context=S,f.__n=r,a=f.__d=!0,f.__h=[]),null==f.__s&&(f.__s=f.state),null!=P.getDerivedStateFromProps&&(f.__s==f.state&&(f.__s=p({},f.__s)),p(f.__s,P.getDerivedStateFromProps(x,f.__s))),y=f.props,v=f.state,a)null==P.getDerivedStateFromProps&&null!=f.componentWillMount&&f.componentWillMount(),null!=f.componentDidMount&&f.__h.push(f.componentDidMount);else{if(null==P.getDerivedStateFromProps&&x!==y&&null!=f.componentWillReceiveProps&&f.componentWillReceiveProps(x,S),!f.__e&&null!=f.shouldComponentUpdate&&!1===f.shouldComponentUpdate(x,f.__s,S)){for(f.props=x,f.state=f.__s,f.__d=!1,f.__v=t,t.__e=n.__e,t.__k=n.__k,f.__h.length&&_.push(f),c=0;c<t.__k.length;c++)t.__k[c]&&(t.__k[c].__=t);break e}null!=f.componentWillUpdate&&f.componentWillUpdate(x,f.__s,S),null!=f.componentDidUpdate&&f.__h.push((function(){f.componentDidUpdate(y,v,m)}))}f.context=S,f.props=x,f.state=f.__s,(c=o.__r)&&c(t),f.__d=!1,f.__v=t,f.__P=e,c=f.render(f.props,f.state,f.context),t.__k=k(null!=c&&c.type==d&&null==c.key?c.props.children:c),null!=f.getChildContext&&(r=p(p({},r),f.getChildContext())),a||null==f.getSnapshotBeforeUpdate||(m=f.getSnapshotBeforeUpdate(y,v)),b(e,t,n,r,l,u,_,i,s),f.base=t.__e,f.__h.length&&_.push(f),g&&(f.__E=f.__=null),f.__e=null}else t.__e=M(n.__e,t,n,r,l,u,_,s);(c=o.diffed)&&c(t)}catch(e){o.__e(e,t,n)}return t.__e}function C(e,t){o.__c&&o.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){o.__e(e,t.__v)}}))}function M(e,t,n,o,r,l,u,s){var p,c,f,a,d,h=n.props,y=t.props;if(r="svg"===t.type||r,null==e&&null!=l)for(p=0;p<l.length;p++)if(null!=(c=l[p])&&(null===t.type?3===c.nodeType:c.localName===t.type)){e=c,l[p]=null;break}if(null==e){if(null===t.type)return document.createTextNode(y);e=r?document.createElementNS("http://www.w3.org/2000/svg",t.type):document.createElement(t.type),l=null}if(null===t.type)null!=l&&(l[l.indexOf(e)]=null),h!==y&&e.data!=y&&(e.data=y);else if(t!==n){if(null!=l&&(l=i.slice.call(e.childNodes)),f=(h=n.props||_).dangerouslySetInnerHTML,a=y.dangerouslySetInnerHTML,!s){if(h===_)for(h={},d=0;d<e.attributes.length;d++)h[e.attributes[d].name]=e.attributes[d].value;(a||f)&&(a&&f&&a.__html==f.__html||(e.innerHTML=a&&a.__html||""))}(function(e,t,n,o,r){var l;for(l in n)l in t||w(e,l,null,n[l],o);for(l in t)r&&"function"!=typeof t[l]||"value"===l||"checked"===l||n[l]===t[l]||w(e,l,t[l],n[l],o)})(e,y,h,r,s),t.__k=t.props.children,a||b(e,t,n,o,"foreignObject"!==t.type&&r,l,u,_,s),s||("value"in y&&void 0!==y.value&&y.value!==e.value&&(e.value=null==y.value?"":y.value),"checked"in y&&void 0!==y.checked&&y.checked!==e.checked&&(e.checked=y.checked))}return e}function j(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){o.__e(e,n)}}function D(e,t,n){var r,l,u;if(o.unmount&&o.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||j(r,null,t)),n||"function"==typeof e.type||(n=null!=(l=e.__e)),e.__e=e.__d=null,null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){o.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(u=0;u<r.length;u++)r[u]&&D(r[u],t,n);null!=l&&c(l)}function N(e,t,n){return this.constructor(e,n)}o={__e:function(e,t){for(var n,o;t=t.__;)if((n=t.__c)&&!n.__)try{if(n.constructor&&null!=n.constructor.getDerivedStateFromError&&(o=!0,n.setState(n.constructor.getDerivedStateFromError(e))),null!=n.componentDidCatch&&(o=!0,n.componentDidCatch(e)),o)return m(n.__E=n)}catch(t){e=t}throw e}},h.prototype.setState=function(e,t){var n;n=this.__s!==this.state?this.__s:this.__s=p({},this.state),"function"==typeof e&&(e=e(n,this.props)),e&&p(n,e),null!=e&&this.__v&&(this.__e=!1,t&&this.__h.push(t),m(this))},h.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),m(this))},h.prototype.render=d,r=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout;var T=function(e,t,n,o){var r;t[0]=0;for(var l=1;l<t.length;l++){var u=t[l++],_=t[l]?(t[0]|=u?1:2,n[t[l++]]):t[++l];3===u?o[0]=_:4===u?o[1]=Object.assign(o[1]||{},_):5===u?(o[1]=o[1]||{})[t[++l]]=_:6===u?o[1][t[++l]]+=_+"":u?(r=e.apply(_,T(e,_,n,["",null])),o.push(r),_[0]?t[0]|=2:(t[l-2]=0,t[l]=r)):o.push(_)}return o},O=new Map,U=function(e){var t=O.get(this);return t||(t=new Map,O.set(this,t)),(t=T(this,t.get(e)||(t.set(e,t=function(e){for(var t,n,o=1,r="",l="",u=[0],_=function(e){1===o&&(e||(r=r.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?u.push(0,e,r):3===o&&(e||r)?(u.push(3,e,r),o=2):2===o&&"..."===r&&e?u.push(4,e,0):2===o&&r&&!e?u.push(5,0,!0,r):o>=5&&((r||!e&&5===o)&&(u.push(o,0,r,n),o=6),e&&(u.push(o,e,0,n),o=6)),r=""},i=0;i<e.length;i++){i&&(1===o&&_(),_(i));for(var s=0;s<e[i].length;s++)t=e[i][s],1===o?"<"===t?(_(),u=[u],o=3):r+=t:4===o?"--"===r&&">"===t?(o=1,r=""):r=t+r[0]:l?t===l?l="":r+=t:'"'===t||"'"===t?l=t:">"===t?(_(),o=1):o&&("="===t?(o=5,n=r,r=""):"/"===t&&(o<5||">"===e[i][s+1])?(_(),3===o&&(u=u[0]),o=u,(u=u[0]).push(2,0,o),o=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(_(),o=2):r+=t),3===o&&"!--"===r&&(o=4,u=u[0])}return _(),u}(e)),t),arguments,[])).length>1?t:t[0]}.bind(f);n.d(t,"html",(function(){return U}))}])}));