/* 脚本引用 https://raw.githubusercontent.com/app2smile/rules/master/js/tieba-proto.js */ console.log('2025-05-06'); // text-decoder !function(i){"use strict";function _(n,e,i){return e<=n&&n<=i}"undefined"!=typeof module&&module.exports&&!i["encoding-indexes"]&&(i["encoding-indexes"]=require("./encoding-indexes.js")["encoding-indexes"]);var l=Math.floor;function s(n){if(void 0===n)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function u(n){return 0<=n&&n<=127}var a=u,b=-1;function c(n){this.tokens=[].slice.call(n),this.tokens.reverse()}c.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():b},prepend:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.push(e.pop());else this.tokens.push(n)},push:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.unshift(e.shift());else this.tokens.unshift(n)}};var w=-1;function m(n,e){if(n)throw TypeError("Decoder error");return e||65533}function f(n){throw TypeError("The code point "+n+" could not be encoded.")}function r(n){return n=String(n).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(d,n)?d[n]:null}var t,o,n=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"},{encodings:[{labels:["866","cp866","csibm866","ibm866"],name:"IBM866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso88592","iso_8859-2","iso_8859-2:1987","l2","latin2"],name:"ISO-8859-2"},{labels:["csisolatin3","iso-8859-3","iso-ir-109","iso8859-3","iso88593","iso_8859-3","iso_8859-3:1988","l3","latin3"],name:"ISO-8859-3"},{labels:["csisolatin4","iso-8859-4","iso-ir-110","iso8859-4","iso88594","iso_8859-4","iso_8859-4:1988","l4","latin4"],name:"ISO-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso-ir-144","iso8859-5","iso88595","iso_8859-5","iso_8859-5:1988"],name:"ISO-8859-5"},{labels:["arabic","asmo-708","csiso88596e","csiso88596i","csisolatinarabic","ecma-114","iso-8859-6","iso-8859-6-e","iso-8859-6-i","iso-ir-127","iso8859-6","iso88596","iso_8859-6","iso_8859-6:1987"],name:"ISO-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso-ir-126","iso8859-7","iso88597","iso_8859-7","iso_8859-7:1987","sun_eu_greek"],name:"ISO-8859-7"},{labels:["csiso88598e","csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-e","iso-ir-138","iso8859-8","iso88598","iso_8859-8","iso_8859-8:1988","visual"],name:"ISO-8859-8"},{labels:["csiso88598i","iso-8859-8-i","logical"],name:"ISO-8859-8-I"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","iso885910","l6","latin6"],name:"ISO-8859-10"},{labels:["iso-8859-13","iso8859-13","iso885913"],name:"ISO-8859-13"},{labels:["iso-8859-14","iso8859-14","iso885914"],name:"ISO-8859-14"},{labels:["csisolatin9","iso-8859-15","iso8859-15","iso885915","iso_8859-15","l9"],name:"ISO-8859-15"},{labels:["iso-8859-16"],name:"ISO-8859-16"},{labels:["cskoi8r","koi","koi8","koi8-r","koi8_r"],name:"KOI8-R"},{labels:["koi8-ru","koi8-u"],name:"KOI8-U"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["dos-874","iso-8859-11","iso8859-11","iso885911","tis-620","windows-874"],name:"windows-874"},{labels:["cp1250","windows-1250","x-cp1250"],name:"windows-1250"},{labels:["cp1251","windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ansi_x3.4-1968","ascii","cp1252","cp819","csisolatin1","ibm819","iso-8859-1","iso-ir-100","iso8859-1","iso88591","iso_8859-1","iso_8859-1:1987","l1","latin1","us-ascii","windows-1252","x-cp1252"],name:"windows-1252"},{labels:["cp1253","windows-1253","x-cp1253"],name:"windows-1253"},{labels:["cp1254","csisolatin5","iso-8859-9","iso-ir-148","iso8859-9","iso88599","iso_8859-9","iso_8859-9:1989","l5","latin5","windows-1254","x-cp1254"],name:"windows-1254"},{labels:["cp1255","windows-1255","x-cp1255"],name:"windows-1255"},{labels:["cp1256","windows-1256","x-cp1256"],name:"windows-1256"},{labels:["cp1257","windows-1257","x-cp1257"],name:"windows-1257"},{labels:["cp1258","windows-1258","x-cp1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gb_2312","gb_2312-80","gbk","iso-ir-58","x-gbk"],name:"GBK"},{labels:["gb18030"],name:"gb18030"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"Big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"EUC-JP"},{labels:["csiso2022jp","iso-2022-jp"],name:"ISO-2022-JP"},{labels:["csshiftjis","ms932","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"Shift_JIS"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"EUC-KR"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["csiso2022kr","hz-gb-2312","iso-2022-cn","iso-2022-cn-ext","iso-2022-kr"],name:"replacement"},{labels:["utf-16be"],name:"UTF-16BE"},{labels:["utf-16","utf-16le"],name:"UTF-16LE"},{labels:["x-user-defined"],name:"x-user-defined"}],heading:"Legacy miscellaneous encodings"}],d={},h=(n.forEach(function(n){n.encodings.forEach(function(e){e.labels.forEach(function(n){d[n]=e})})}),{}),g={};function y(n,e){return e&&e[n]||null}function p(n,e){e=e.indexOf(n);return-1===e?null:e}function v(n){if("encoding-indexes"in i)return i["encoding-indexes"][n];throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?")}var x="utf-8";function O(n,e){if(!(this instanceof O))throw TypeError("Called as a function. Did you forget 'new'?");n=void 0!==n?String(n):x,e=s(e),this._encoding=null,this._decoder=null,this._ignoreBOM=!1,this._BOMseen=!1,this._error_mode="replacement",this._do_not_flush=!1;var i=r(n);if(null===i||"replacement"===i.name)throw RangeError("Unknown encoding: "+n);if(g[i.name])return(n=this)._encoding=i,Boolean(e.fatal)&&(n._error_mode="fatal"),Boolean(e.ignoreBOM)&&(n._ignoreBOM=!0),Object.defineProperty||(this.encoding=n._encoding.name.toLowerCase(),this.fatal="fatal"===n._error_mode,this.ignoreBOM=n._ignoreBOM),n;throw Error("Decoder not present. Did you forget to include encoding-indexes.js first?")}function k(n,e){if(!(this instanceof k))throw TypeError("Called as a function. Did you forget 'new'?");e=s(e),this._encoding=null,this._encoder=null,this._do_not_flush=!1,this._fatal=Boolean(e.fatal)?"fatal":"replacement";if(Boolean(e.NONSTANDARD_allowLegacyEncoding)){e=r(n=void 0!==n?String(n):x);if(null===e||"replacement"===e.name)throw RangeError("Unknown encoding: "+n);if(!h[e.name])throw Error("Encoder not present. Did you forget to include encoding-indexes.js first?");this._encoding=e}else this._encoding=r("utf-8"),void 0!==n&&"console"in i&&console.warn("TextEncoder constructor called with encoding label, which is ignored.");return Object.defineProperty||(this.encoding=this._encoding.name.toLowerCase()),this}function e(n){var r=n.fatal,t=0,o=0,s=0,l=128,a=191;this.handler=function(n,e){if(e===b&&0!==s)return s=0,m(r);if(e===b)return w;if(0===s){if(_(e,0,127))return e;if(_(e,194,223))s=1,t=31&e;else if(_(e,224,239))224===e&&(l=160),237===e&&(a=159),s=2,t=15&e;else{if(!_(e,240,244))return m(r);240===e&&(l=144),244===e&&(a=143),s=3,t=7&e}return null}var i;return _(e,l,a)?(l=128,a=191,t=t<<6|63&e,(o+=1)!==s?null:(i=t,t=s=o=0,i)):(t=s=o=0,l=128,a=191,n.prepend(e),m(r))}}function E(n){n.fatal;this.handler=function(n,e){if(e===b)return w;if(a(e))return e;_(e,128,2047)?(i=1,r=192):_(e,2048,65535)?(i=2,r=224):_(e,65536,1114111)&&(i=3,r=240);for(var i,r,t=[(e>>6*i)+r];0>6*(i-1)),--i;return t}}function j(i,n){var r=n.fatal;this.handler=function(n,e){return e===b?w:u(e)?e:null===(e=i[e-128])?m(r):e}}function B(r,n){n.fatal;this.handler=function(n,e){var i;return e===b?w:a(e)?e:(null===(i=p(e,r))&&f(e),i+128)}}function S(n){var o=n.fatal,s=0,l=0,a=0;this.handler=function(n,e){var i,r,t;return e===b&&0===s&&0===l&&0===a?w:(e!==b||0===s&&0===l&&0===a||(a=l=s=0,m(o)),0!==a?(i=null,_(e,48,57)&&(i=function(n){if(39419>8,n=255&n;return e?[i,n]:[n,i]}function L(r,n){var t=n.fatal,o=null,s=null;this.handler=function(n,e){var i;return e!==b||null===o&&null===s?e===b&&null===o&&null===s?w:null===o?(o=e,null):(e=r?(o<<8)+e:(e<<8)+o,(o=null)!==s?(i=s,s=null,_(e,56320,57343)?65536+1024*(i-55296)+(e-56320):(n.prepend(A(e,r)),m(t))):_(e,55296,56319)?(s=e,null):_(e,56320,57343)?m(t):e):m(t)}}function M(r,n){n.fatal;this.handler=function(n,e){var i;return e===b?w:_(e,0,65535)?A(e,r):(i=A(55296+(e-65536>>10),r),e=A(56320+(e-65536&1023),r),i.concat(e))}}function N(n){n.fatal;this.handler=function(n,e){return e===b?w:u(e)?e:63360+e-128}}function q(n){n.fatal;this.handler=function(n,e){return e===b?w:a(e)?e:_(e,63360,63487)?e-63360+128:f(e)}}Object.defineProperty&&(Object.defineProperty(O.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(O.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(O.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),O.prototype.decode=function(n,e){n="object"==typeof n&&n instanceof ArrayBuffer?new Uint8Array(n):"object"==typeof n&&"buffer"in n&&n.buffer instanceof ArrayBuffer?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(0);e=s(e),this._do_not_flush||(this._decoder=g[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=Boolean(e.stream);for(var i,r=new c(n),t=[];;){var o=r.read();if(o===b)break;if((i=this._decoder.handler(r,o))===w)break;null!==i&&(Array.isArray(i)?t.push.apply(t,i):t.push(i))}if(!this._do_not_flush){for(;(i=this._decoder.handler(r,r.read()))!==w&&(null!==i&&(Array.isArray(i)?t.push.apply(t,i):t.push(i)),!r.endOfStream()););this._decoder=null}return function(n){e=["UTF-8","UTF-16LE","UTF-16BE"],i=this._encoding.name,-1===e.indexOf(i)||this._ignoreBOM||this._BOMseen||(0>10),56320+(1023&s)))}return t}.call(this,t)},Object.defineProperty&&Object.defineProperty(k.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),k.prototype.encode=function(n,e){n=void 0===n?"":String(n),e=s(e),this._do_not_flush||(this._encoder=h[this._encoding.name]({fatal:"fatal"===this._fatal})),this._do_not_flush=Boolean(e.stream);for(var i,r=new c(function(n){for(var e=String(n),i=e.length,r=0,t=[];r{s.symbol=Symbol.for("protobuf-ts/unknown"),s.onRead=(e,r,t,a,n)=>{(i(r)?r[s.symbol]:r[s.symbol]=[]).push({no:t,wireType:a,data:n})},s.onWrite=(e,r,t)=>{for(var{no:a,wireType:n,data:i}of s.list(r))t.tag(a,n).raw(i)},s.list=(e,r)=>i(e)?(e=e[s.symbol],r?e.filter(e=>e.no==r):e):[],s.last=(e,r)=>s.list(e,r).slice(-1)[0];let i=e=>e&&Array.isArray(e[s.symbol])})(UnknownFieldHandler=UnknownFieldHandler||{});var UnknownFieldHandler,WireType=(e=>(e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32",e))(WireType||{});let MESSAGE_TYPE=Symbol.for("protobuf-ts/message-type");function lowerCamelCase(r){let t=!1;var a=[];for(let e=0;e(e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64",e))(ScalarType||{}),LongType=(e=>(e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER",e))(LongType||{}),RepeatType=(e=>(e[e.NO=0]="NO",e[e.PACKED=1]="PACKED",e[e.UNPACKED=2]="UNPACKED",e))(RepeatType||{});function normalizeFieldInfo(e){var r;return e.localName=null!=(r=e.localName)?r:lowerCamelCase(e.name),e.jsonName=null!=(r=e.jsonName)?r:lowerCamelCase(e.name),e.repeat=null!=(r=e.repeat)?r:0,e.opt=null!=(r=e.opt)?r:!e.repeat&&!e.oneof&&"message"==e.kind,e}function isOneofGroup(e){if("object"!=typeof e||null===e||!e.hasOwnProperty("oneofKind"))return!1;switch(typeof e.oneofKind){case"string":return void 0===e[e.oneofKind]?!1:2==Object.keys(e).length;case"undefined":return 1==Object.keys(e).length;default:return!1}}class ReflectionTypeCheck{constructor(e){this.fields=null!=(e=e.fields)?e:[]}prepare(){if(!this.data){var e,r=[],t=[],a=[];for(e of this.fields)if(e.oneof)a.includes(e.oneof)||(a.push(e.oneof),r.push(e.oneof),t.push(e.oneof));else switch(t.push(e.localName),e.kind){case"scalar":case"enum":e.opt&&!e.repeat||r.push(e.localName);break;case"message":e.repeat&&r.push(e.localName);break;case"map":r.push(e.localName)}this.data={req:r,known:t,oneofs:Object.values(a)}}}is(e,a,n=!1){if(!(a<0)){if(null==e||"object"!=typeof e)return!1;this.prepare();let r=Object.keys(e),t=this.data;if(r.length!r.includes(e)))return!1;if(!n&&r.some(e=>!t.known.includes(e)))return!1;if(!(a<1)){for(var i of t.oneofs){let r=e[i];if(!isOneofGroup(r))return!1;if(void 0!==r.oneofKind){i=this.fields.find(e=>e.localName===r.oneofKind);if(!i)return!1;if(!this.field(r[r.oneofKind],i,n,a))return!1}}for(var s of this.fields)if(void 0===s.oneof&&!this.field(e[s.localName],s,n,a))return!1}}return!0}field(e,r,t,a){var n=r.repeat;switch(r.kind){case"scalar":return void 0===e?r.opt:n?this.scalars(e,r.T,a,r.L):this.scalar(e,r.T,r.L);case"enum":return void 0===e?r.opt:n?this.scalars(e,ScalarType.INT32,a):this.scalar(e,ScalarType.INT32);case"message":return void 0===e?!0:n?this.messages(e,r.T(),t,a):this.message(e,r.T(),t,a);case"map":if("object"!=typeof e||null===e)return!1;if(a<2)return!0;if(!this.mapKeys(e,r.K,a))return!1;switch(r.V.kind){case"scalar":return this.scalars(Object.values(e),r.V.T,a,r.V.L);case"enum":return this.scalars(Object.values(e),ScalarType.INT32,a);case"message":return this.messages(Object.values(e),r.V.T(),t,a)}}return!0}message(e,r,t,a){return t?r.isAssignable(e,a):r.is(e,a)}messages(r,t,e,a){if(!Array.isArray(r))return!1;if(!(a<2))if(e){for(let e=0;eparseInt(e)),r,t);case ScalarType.BOOL:return this.scalars(a.slice(0,t).map(e=>"true"==e||"false"!=e&&e),r,t);default:return this.scalars(a,r,t,LongType.STRING)}}}function typeofJsonValue(e){var r=typeof e;if("object"==r){if(Array.isArray(e))return"array";if(null===e)return"null"}return r}function isJsonObject(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}let encTable="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),decTable=[];for(let e=0;e>4,s=i,n=2;break;case 2:t[a++]=(15&s)<<4|(60&i)>>2,s=i,n=3;break;case 3:t[a++]=(3&s)<<6|i,n=0}}if(1==n)throw Error("invalid base64 string.");return t.subarray(0,a)}function base64encode(r){let t="",a=0,n,i=0;for(let e=0;e>2],i=(3&n)<<4,a=1;break;case 1:t+=encTable[i|n>>4],i=(15&n)<<2,a=2;break;case 2:t=(t+=encTable[i|n>>6])+encTable[63&n],a=0}return a&&(t=t+encTable[i]+"=",1==a)&&(t+="="),t}function varint64read(){let r=0,t=0;for(let e=0;e<28;e+=7){var a=this.buf[this.pos++];if(r|=(127&a)<>4,0==(128&e))return this.assertBounds(),[r,t];for(let e=3;e<=31;e+=7){var n=this.buf[this.pos++];if(t|=(127&n)<>>e,i=!(n>>>7==0&&0==t);if(a.push(255&(i?128|n:n)),!i)return}var e=r>>>28&15|(7&t)<<4,s=!(t>>3==0);if(a.push(255&(s?128|e:e)),s){for(let e=3;e<31;e+=7){var o=t>>>e,l=!(o>>>7==0);if(a.push(255&(l?128|o:o)),!l)return}a.push(t>>>31&1)}}decTable["-".charCodeAt(0)]=encTable.indexOf("+"),decTable["_".charCodeAt(0)]=encTable.indexOf("/");let TWO_PWR_32_DBL$1=4294967296;function int64fromString(t){var e="-"==t[0];e&&(t=t.slice(1));let a=0,n=0;function r(e,r){e=Number(t.slice(e,r));n*=1e6,(a=1e6*a+e)>=TWO_PWR_32_DBL$1&&(n+=a/TWO_PWR_32_DBL$1|0,a%=TWO_PWR_32_DBL$1)}return r(-24,-18),r(-18,-12),r(-12,-6),r(-6),[e,a,n]}function int64toString(e,r){if(r>>>0<=2097151)return""+(TWO_PWR_32_DBL$1*r+(e>>>0));var t=(e>>>24|r<<8)>>>0&16777215,r=r>>16&65535;let a=(16777215&e)+6777216*t+6710656*r,n=t+8147497*r,i=2*r;function s(e,r){e=e?String(e):"";return r?"0000000".slice(e.length)+e:e}return 1e7<=a&&(n+=Math.floor(a/1e7),a%=1e7),1e7<=n&&(i+=Math.floor(n/1e7),n%=1e7),s(i,0)+s(n,i)+s(a,1)}function varint32write(r,t){if(0<=r){for(;127>>=7;t.push(r)}else{for(let e=0;e<9;e++)t.push(127&r|128),r>>=7;t.push(1)}}function varint32read(){let r=this.buf[this.pos++];var e=127&r;if(0==(128&r))return this.assertBounds(),e;if(e|=(127&(r=this.buf[this.pos++]))<<7,0==(128&r))return this.assertBounds(),e;if(e|=(127&(r=this.buf[this.pos++]))<<14,0==(128&r))return this.assertBounds(),e;if(e|=(127&(r=this.buf[this.pos++]))<<21,0==(128&r))return this.assertBounds(),e;e|=(15&(r=this.buf[this.pos++]))<<28;for(let e=5;0!=(128&r)&&e<10;e++)r=this.buf[this.pos++];if(0!=(128&r))throw new Error("invalid varint");return this.assertBounds(),e>>>0}let BI;function detectBi(){var e=new DataView(new ArrayBuffer(8)),r=void 0!==globalThis.BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64;BI=r?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:e}:void 0}function assertBi(e){if(!e)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}detectBi();let RE_DECIMAL_STR=/^-?[0-9]+$/,TWO_PWR_32_DBL=4294967296,HALF_2_PWR_32=2147483648;class SharedPbLong{constructor(e,r){this.lo=0|e,this.hi=0|r}isZero(){return 0==this.lo&&0==this.hi}toNumber(){var e=this.hi*TWO_PWR_32_DBL+(this.lo>>>0);if(Number.isSafeInteger(e))return e;throw new Error("cannot convert to safe number")}}let _PbULong=class extends SharedPbLong{static from(e){if(BI)switch(typeof e){case"string":if("0"==e)return this.ZERO;if(""==e)throw new Error("string is no integer");e=BI.C(e);case"number":if(0===e)return this.ZERO;e=BI.C(e);case"bigint":if(!e)return this.ZERO;if(eBI.UMAX)throw new Error("ulong too large");return BI.V.setBigUint64(0,e,!0),new _PbULong(BI.V.getInt32(0,!0),BI.V.getInt32(4,!0))}else switch(typeof e){case"string":if("0"==e)return this.ZERO;if(e=e.trim(),!RE_DECIMAL_STR.test(e))throw new Error("string is no integer");var[r,t,a]=int64fromString(e);if(r)throw new Error("signed value for ulong");return new _PbULong(t,a);case"number":if(0==e)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new _PbULong(e,e/TWO_PWR_32_DBL)}throw new Error("unknown value "+typeof e)}toString(){return BI?this.toBigInt().toString():int64toString(this.lo,this.hi)}toBigInt(){return assertBi(BI),BI.V.setInt32(0,this.lo,!0),BI.V.setInt32(4,this.hi,!0),BI.V.getBigUint64(0,!0)}},PbULong=_PbULong,_PbLong=(PbULong.ZERO=new _PbULong(0,0),class extends SharedPbLong{static from(e){if(BI)switch(typeof e){case"string":if("0"==e)return this.ZERO;if(""==e)throw new Error("string is no integer");e=BI.C(e);case"number":if(0===e)return this.ZERO;e=BI.C(e);case"bigint":if(!e)return this.ZERO;if(eBI.MAX)throw new Error("signed long too large");return BI.V.setBigInt64(0,e,!0),new _PbLong(BI.V.getInt32(0,!0),BI.V.getInt32(4,!0))}else switch(typeof e){case"string":if("0"==e)return this.ZERO;if(e=e.trim(),!RE_DECIMAL_STR.test(e))throw new Error("string is no integer");var[r,t,a]=int64fromString(e);if(r){if(a>HALF_2_PWR_32||a==HALF_2_PWR_32&&0!=t)throw new Error("signed long too small")}else if(a>=HALF_2_PWR_32)throw new Error("signed long too large");t=new _PbLong(t,a);return r?t.negate():t;case"number":if(0==e)return this.ZERO;if(Number.isSafeInteger(e))return 0INT32_MAX||eUINT32_MAX||e<0)throw new Error("invalid uint 32: "+e)}function assertFloat32(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>FLOAT32_MAX||e[e.no,e])))}read(a,n,i,e){this.prepare();for(var r=void 0===e?a.len:a.pos+e;a.pose.no-r.no))}write(n,i,s){this.prepare();for(var o of this.fields){let e,r,t=o.repeat,a=o.localName;if(o.oneof){var l=n[o.oneof];if(l.oneofKind!==a)continue;e=l[a],r=!0}else e=n[a],r=!1;switch(o.kind){case"scalar":case"enum":var c="enum"==o.kind?ScalarType.INT32:o.T;if(t)if(assert(Array.isArray(e)),t==RepeatType.PACKED)this.packed(i,c,o.no,e);else for(var u of e)this.scalar(i,c,o.no,u,!0);else void 0===e?assert(o.opt):this.scalar(i,c,o.no,e,r||o.opt);break;case"message":if(t){assert(Array.isArray(e));for(var f of e)this.message(i,s,o.T(),o.no,f)}else this.message(i,s,o.T(),o.no,e);break;case"map":assert("object"==typeof e&&null!==e);for(var[h,p]of Object.entries(e))this.mapEntry(i,s,o,h,p)}}var e=s.writeUnknownFields;!1!==e&&(!0===e?UnknownFieldHandler.onWrite:e)(this.info.typeName,n,i)}mapEntry(e,r,t,a,n){e.tag(t.no,WireType.LengthDelimited),e.fork();let i=a;switch(t.K){case ScalarType.INT32:case ScalarType.FIXED32:case ScalarType.UINT32:case ScalarType.SFIXED32:case ScalarType.SINT32:i=Number.parseInt(a);break;case ScalarType.BOOL:assert("true"==a||"false"==a),i="true"==a}switch(this.scalar(e,t.K,1,i,!0),t.V.kind){case"scalar":this.scalar(e,t.V.T,2,n,!0);break;case"enum":this.scalar(e,ScalarType.INT32,2,n,!0);break;case"message":this.message(e,r,t.V.T(),2,n)}e.join()}message(e,r,t,a,n){void 0!==n&&(t.internalBinaryWrite(n,e.tag(a,WireType.LengthDelimited).fork(),r),e.join())}scalar(e,r,t,a,n){var[r,i,s]=this.scalarInfo(r,a);s&&!n||(e.tag(t,r),e[i](a))}packed(r,e,t,a){if(a.length){assert(e!==ScalarType.BYTES&&e!==ScalarType.STRING),r.tag(t,WireType.LengthDelimited),r.fork();var[,n]=this.scalarInfo(e);for(let e=0;enew BinaryWriter};function binaryWriteOptions(e){return e?{...defaultsWrite,...e}:defaultsWrite}class BinaryWriter{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let r=0;for(let e=0;e>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(assertUInt32(e);127>>=7;return this.buf.push(e),this}int32(e){return assertInt32(e),varint32write(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){e=this.textEncoder.encode(e);return this.uint32(e.byteLength),this.raw(e)}float(e){assertFloat32(e);var r=new Uint8Array(4);return new DataView(r.buffer).setFloat32(0,e,!0),this.raw(r)}double(e){var r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,e,!0),this.raw(r)}fixed32(e){assertUInt32(e);var r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e,!0),this.raw(r)}sfixed32(e){assertInt32(e);var r=new Uint8Array(4);return new DataView(r.buffer).setInt32(0,e,!0),this.raw(r)}sint32(e){return assertInt32(e),varint32write(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){var r=new Uint8Array(8),t=new DataView(r.buffer),e=PbLong.from(e);return t.setInt32(0,e.lo,!0),t.setInt32(4,e.hi,!0),this.raw(r)}fixed64(e){var r=new Uint8Array(8),t=new DataView(r.buffer),e=PbULong.from(e);return t.setInt32(0,e.lo,!0),t.setInt32(4,e.hi,!0),this.raw(r)}int64(e){e=PbLong.from(e);return varint64write(e.lo,e.hi,this.buf),this}sint64(e){var e=PbLong.from(e),r=e.hi>>31;return varint64write(e.lo<<1^r,(e.hi<<1|e.lo>>>31)^r,this.buf),this}uint64(e){e=PbULong.from(e);return varint64write(e.lo,e.hi,this.buf),this}}let defaultsRead={readUnknownField:!0,readerFactory:e=>new BinaryReader(e)};function binaryReadOptions(e){return e?{...defaultsRead,...e}:defaultsRead}class BinaryReader{constructor(e,r){this.varint64=varint64read,this.uint32=varint32read,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=r?r:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){var e=this.uint32(),r=e>>>3,e=7&e;if(r<=0||e<0||5this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){var e=this.uint32();return e>>>1^-(1&e)}int64(){return new PbLong(...this.varint64())}uint64(){return new PbULong(...this.varint64())}sint64(){var[e,r]=this.varint64(),t=-(1&e),e=(e>>>1|(1&r)<<31)^t,r=r>>>1^t;return new PbLong(e,r)}bool(){var[e,r]=this.varint64();return 0!==e||0!==r}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new PbULong(this.sfixed32(),this.sfixed32())}sfixed64(){return new PbLong(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){var e=this.uint32(),r=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(r,r+e)}string(){return this.textDecoder.decode(this.bytes())}}let baseDescriptors=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class MessageType{constructor(e,r,t){this.defaultCheckDepth=16,this.typeName=e,this.fields=r.map(normalizeFieldInfo),this.options=null!=t?t:{},this.messagePrototype=Object.create(null,{...baseDescriptors,[MESSAGE_TYPE]:{value:this}}),this.refTypeCheck=new ReflectionTypeCheck(this),this.refJsonReader=new ReflectionJsonReader(this),this.refJsonWriter=new ReflectionJsonWriter(this),this.refBinReader=new ReflectionBinaryReader(this),this.refBinWriter=new ReflectionBinaryWriter(this)}create(e){var r=reflectionCreate(this);return void 0!==e&&reflectionMergePartial(this,r,e),r}clone(e){var r=this.create();return reflectionMergePartial(this,r,e),r}equals(e,r){return reflectionEquals(this,e,r)}is(e,r=this.defaultCheckDepth){return this.refTypeCheck.is(e,r,!1)}isAssignable(e,r=this.defaultCheckDepth){return this.refTypeCheck.is(e,r,!0)}mergePartial(e,r){reflectionMergePartial(this,e,r)}fromBinary(e,r){r=binaryReadOptions(r);return this.internalBinaryRead(r.readerFactory(e),e.byteLength,r)}fromJson(e,r){return this.internalJsonRead(e,jsonReadOptions(r))}fromJsonString(e,r){e=JSON.parse(e);return this.fromJson(e,r)}toJson(e,r){return this.internalJsonWrite(e,jsonWriteOptions(r))}toJsonString(e,r){var e=this.toJson(e,r);return JSON.stringify(e,null,null!=(e=null==r?void 0:r.prettySpaces)?e:0)}toBinary(e,r){r=binaryWriteOptions(r);return this.internalBinaryWrite(e,r.writerFactory(),r).finish()}internalJsonRead(e,r,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw new Error(`Unable to parse message ${this.typeName} from JSON ${typeofJsonValue(e)}.`);return t=null!=t?t:this.create(),this.refJsonReader.read(e,t,r),t}internalJsonWrite(e,r){return this.refJsonWriter.write(e,r)}internalBinaryWrite(e,r,t){return this.refBinWriter.write(e,r,t),r}internalBinaryRead(e,r,t,a){a=null!=a?a:this.create();return this.refBinReader.read(e,a,t,r),a}} class FrsPageResIdl$Type extends MessageType{constructor(){super("FrsPageResIdl",[{no:2,name:"data",kind:"message",T:()=>FrsPageDataRes}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posForumInfo},{no:7,name:"thread_list",kind:"message",repeat:2,T:()=>ThreadInfo},{no:23,name:"activityhead",kind:"message",T:()=>ActivityHead},{no:116,name:"live_fuse_forum",kind:"message",repeat:2,T:()=>LiveFuseForumData},{no:126,name:"page_data",kind:"message",T:()=>PageData}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return n.threadList=[],n.liveFuseForum=[],void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posLayoutFactory}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return n.feedList=[],void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posBannerList}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posPbPageDataRes}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posBannerList},{no:55,name:"recom_ala_info",kind:"message",T:()=>AlaLiveInfo},{no:6,name:"post_list",kind:"message",repeat:2,T:()=>Post}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return n.postList=[],void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posPersonalizedDataRes}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posBannerList},{no:2,name:"thread_list",kind:"message",repeat:2,T:()=>ThreadInfo},{no:17,name:"live_answer",kind:"message",T:()=>LiveAnswer}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return n.threadList=[],void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posThreadListDataRes}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posBannerList}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posGeneralTabListDataRes}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posApp}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return n.appList=[],void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posApp},{no:5,name:"pb_banner_ad",kind:"message",T:()=>App}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return n.app=[],void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posGoodsInfo},{no:38,name:"live_ad",kind:"message",T:()=>LiveAdData}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return n.goodsInfo=[],void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posAlaLiveInfo}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posVideoInfo},{no:113,name:"ala_info",kind:"message",T:()=>AlaLiveInfo}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posItem},{no:67,name:"novel_recom_card",kind:"message",T:()=>NovelRecomCard}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posFeedLayout}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.posFeedKV}])}create(e){var n=globalThis.Object.create(this.messagePrototype);return n.businessInfo=[],void 0!==e&&reflectionMergePartial(this,n,e),n}internalBinaryRead(e,n,r,a){for(var t=null!=a?a:this.create(),i=e.pos+n;e.pos { if(item.feed == null || item.feed.businessInfo == null){ return true; } const isLive = item.feed.businessInfo.some(el => el.key === 'is_live_card' && el.value === '1'); if(isLive){ liveCount++; } return !isLive; }); if(liveCount){ console.log(`去除frs帖子直播${liveCount}`) } } body = FrsPageResIdl.toBinary(frsPageResIdlObj); } else if (url.includes("pb/page")) { console.log('贴吧-PbPage'); const pbPageResIdlObj = PbPageResIdl.fromBinary(binaryBody,{readUnknownField: true}); removeGoodsInfo(pbPageResIdlObj.data.bannerList?.app); const bannerGoodsInfoLength = pbPageResIdlObj.data.bannerList?.pbBannerAd?.goodsInfo?.length; if (bannerGoodsInfoLength) { console.log(`去除pb_banner_ad的goods_info:${bannerGoodsInfoLength}`) pbPageResIdlObj.data.bannerList.pbBannerAd.goodsInfo = []; } if(pbPageResIdlObj.data.bannerList?.pbBannerAd?.liveAd){ console.log(`去除pb_banner_ad的live_ad`) pbPageResIdlObj.data.bannerList.pbBannerAd.liveAd = null; } if(pbPageResIdlObj.data.recomAlaInfo?.liveId){ console.log('帖子详情页推荐的直播广告去除'); pbPageResIdlObj.data.recomAlaInfo = null; } else { console.log('帖子详情页无直播广告'); } if(pbPageResIdlObj.data.postList?.length){ for (const post of pbPageResIdlObj.data.postList) { if(post.outerItem){ console.log('outer_item去除'); post.outerItem = null; } if(post.novelRecomCard){ console.log('小说推荐卡去除'); post.novelRecomCard = null; } } } else { console.log('无需处理postList'); } body = PbPageResIdl.toBinary(pbPageResIdlObj); } else if (url.includes("excellent/personalized")) { console.log('贴吧-personalized'); const argOptions = { per_filter_video_thread: 0, }; if (typeof $argument !== 'undefined') { const params = Object.fromEntries($argument.split('&').map(item => item.split('='))); Object.assign(argOptions, params); } const personalizedResIdlObj = PersonalizedResIdl.fromBinary(binaryBody,{readUnknownField: true}); removeGoodsInfo(personalizedResIdlObj.data.bannerList?.app); personalizedResIdlObj.data.threadList = removeThread(personalizedResIdlObj.data.threadList, +argOptions.per_filter_video_thread); if(personalizedResIdlObj.data.liveAnswer){ console.log('去除推荐页上方的banner广告'); personalizedResIdlObj.data.liveAnswer = null; } else { console.log('推荐页无banner广告'); } body = PersonalizedResIdl.toBinary(personalizedResIdlObj); } else if (url.includes("frs/threadlist")) { console.log('贴吧-threadlist'); const threadListResIdlObj = ThreadListResIdl.fromBinary(binaryBody,{readUnknownField: true}); removeGoodsInfo(threadListResIdlObj.data.bannerList?.app); body = ThreadListResIdl.toBinary(threadListResIdlObj); } else if (url.includes("frs/generalTabList")) { console.log('贴吧-generalTabList'); const generalTabListResIdlObj = GeneralTabListResIdl.fromBinary(binaryBody,{readUnknownField: true}); removeGoodsInfo(generalTabListResIdlObj.data.appList); body = GeneralTabListResIdl.toBinary(generalTabListResIdlObj); } else { $notification.post('贴吧proto去广告脚本错误', "url匹配错误:", url); } if(isQuanX){ $done({bodyBytes: body.buffer.slice(body.byteOffset, body.byteLength + body.byteOffset)}); } else { $done({body}); } } function removeGoodsInfo(app) { if (app?.length) { let goodsInfoSize = 0; app.forEach(item => { if (item.goodsInfo?.length) { goodsInfoSize++; item.goodsInfo = []; } }) if (goodsInfoSize) { console.log(`去除goods_info:${goodsInfoSize}`); } else { console.log(`app内无goods_info`) } } else { console.log(`app为空,无需处理`); } } function removeThread(threadList, filterVideo) { let newThreadList = threadList; let liveCount = 0; let videoCount = 0; if(threadList?.length){ newThreadList = threadList.filter(item => { if(item.alaInfo){ liveCount++; return false; } else if(filterVideo && item.videoInfo){ videoCount++; return false; } return true; }); console.log(`去除帖子:直播${liveCount} / 视频${videoCount}`) } else { console.log('无需处理threadList'); } return newThreadList; }