From ef63cbb41e93281f2383e4de1d727782754d5539 Mon Sep 17 00:00:00 2001 From: Robot-Inventor <30.keita@gmail.com> Date: Tue, 13 Aug 2024 02:25:58 +0900 Subject: [PATCH] 2.1.2 --- index.user.js | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.user.js b/index.user.js index bbd582b..a4adb14 100644 --- a/index.user.js +++ b/index.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Hide View Count // @namespace https://github.com/Robot-Inventor/hide-view-count -// @version 2.1.1 +// @version 2.1.2 // @description This extension hides the number of impressions on Twitter and prevents the creation of an approval desire monster. It won't allow the View Count to be displayed for even a second! // @author Robot-Inventor (ろぼいん / @keita_roboin) // @match https://twitter.com/* @@ -16,4 +16,4 @@ // @grant none // ==/UserScript== /*! For license information please see index.user.js.LICENSE.txt */ -(()=>{"use strict";var e={531:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function p(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(p,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.asyncQuerySelectorAll=t.asyncQuerySelector=void 0;const n=(e,t)=>new Promise((r=>{const n=e();if(n instanceof Element||n instanceof NodeList&&n.length)return void r(n);let o=null;const i=new MutationObserver((()=>{const t=e();(t instanceof Element||t instanceof NodeList&&t.length)&&(i.disconnect(),o&&clearTimeout(o),r(t))}));o=setTimeout((()=>{i.disconnect(),r(null)}),t),i.observe(document.body,{attributes:!0,childList:!0,subtree:!0})}));t.asyncQuerySelector=(e,...t)=>r(void 0,[e,...t],void 0,(function*(e,t=document,r=500){return yield n((()=>t.querySelector(e)),r)})),t.asyncQuerySelectorAll=(e,...t)=>r(void 0,[e,...t],void 0,(function*(e,t=document,r=500){var o;return null!==(o=yield n((()=>t.querySelectorAll(e)),r))&&void 0!==o?o:document.createDocumentFragment().childNodes}))},146:(e,t,r)=>{r.r(t),r.d(t,{Profile:()=>o,Timeline:()=>f,Tweet:()=>p});const n=e=>{const t=Object.getOwnPropertyNames(e).filter((e=>e.startsWith("__reactProps$")));return t.length?e[t[0]]:null};class o{profileElement;constructor(e){this.profileElement=e}get props(){const e=n(this.profileElement);if(!function(e){const t=e;return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.children)&&(null!==t.children[1]&&"object"==typeof t.children[1]||"function"==typeof t.children[1])&&(null!==t.children[1].props&&"object"==typeof t.children[1].props||"function"==typeof t.children[1].props)&&(null!==t.children[1].props.user&&"object"==typeof t.children[1].props.user||"function"==typeof t.children[1].props.user)&&(void 0===t.children[1].props.user.possibly_sensitive||null===t.children[1].props.user.possibly_sensitive||!1===t.children[1].props.user.possibly_sensitive||!0===t.children[1].props.user.possibly_sensitive)&&"string"==typeof t.children[1].props.user.screen_name&&(""===t.children[1].props.user.profile_interstitial_type||"sensitive_media"===t.children[1].props.user.profile_interstitial_type||"fake_account"===t.children[1].props.user.profile_interstitial_type||"offensive_profile_content"===t.children[1].props.user.profile_interstitial_type||"timeout"===t.children[1].props.user.profile_interstitial_type)&&Array.isArray(t.children[1].props.user.withheld_in_countries)&&t.children[1].props.user.withheld_in_countries.every((e=>"string"==typeof e))}(e))throw new Error("Failed to get React props of profile");return e.children[1].props.user}}var i=r(531);class p{tweetElement;constructor(e){this.tweetElement=e}getMenuBar(){const e=this.tweetElement.querySelector("div[role='group'][id]");if(!e)throw new Error("Failed to get menu bar of tweet");return e}get element(){return this.tweetElement}get props(){const e=n(this.getMenuBar());if(!function(e){const t=e;return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.children)&&(null!==t.children[1]&&"object"==typeof t.children[1]||"function"==typeof t.children[1])&&(null!==t.children[1].props&&"object"==typeof t.children[1].props||"function"==typeof t.children[1].props)&&(null!==t.children[1].props.retweetWithCommentLink&&"object"==typeof t.children[1].props.retweetWithCommentLink||"function"==typeof t.children[1].props.retweetWithCommentLink)&&(null!==t.children[1].props.retweetWithCommentLink.state&&"object"==typeof t.children[1].props.retweetWithCommentLink.state||"function"==typeof t.children[1].props.retweetWithCommentLink.state)&&(null!==t.children[1].props.retweetWithCommentLink.state.quotedStatus&&"object"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus||"function"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus)&&(void 0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive||null===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive||!1===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive||!0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive)&&(void 0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive_editable||null===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive_editable||!1===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive_editable||!0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive_editable)&&"string"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus.permalink&&(null!==t.children[1].props.retweetWithCommentLink.state.quotedStatus.user&&"object"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus.user||"function"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus.user)&&(void 0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.possibly_sensitive||null===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.possibly_sensitive||!1===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.possibly_sensitive||!0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.possibly_sensitive)&&"string"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.screen_name&&(""===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type||"sensitive_media"===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type||"fake_account"===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type||"offensive_profile_content"===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type||"timeout"===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type)&&Array.isArray(t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.withheld_in_countries)&&t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.withheld_in_countries.every((e=>"string"==typeof e))}(e))throw new Error("Failed to get React props of tweet");return e.children[1].props.retweetWithCommentLink.state.quotedStatus}get metadata(){const e=this.props.user.screen_name,t=n(this.element);if(!t)throw new Error("Failed to get React props of tweet");let r=null;const o=function(e){const t=e;return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.children)&&Array.isArray(t.children[0])&&(null!==t.children[0][1]&&"object"==typeof t.children[0][1]||"function"==typeof t.children[0][1])&&(null!==t.children[0][1].props&&"object"==typeof t.children[0][1].props||"function"==typeof t.children[0][1].props)&&Array.isArray(t.children[0][1].props.children)&&(null!==t.children[0][1].props.children[0]&&"object"==typeof t.children[0][1].props.children[0]||"function"==typeof t.children[0][1].props.children[0])&&(null!==t.children[0][1].props.children[0].props&&"object"==typeof t.children[0][1].props.children[0].props||"function"==typeof t.children[0][1].props.children[0].props)&&Array.isArray(t.children[0][1].props.children[0].props.children)&&(null!==t.children[0][1].props.children[0].props.children[2]&&"object"==typeof t.children[0][1].props.children[0].props.children[2]||"function"==typeof t.children[0][1].props.children[0].props.children[2])&&(null!==t.children[0][1].props.children[0].props.children[2].props&&"object"==typeof t.children[0][1].props.children[0].props.children[2].props||"function"==typeof t.children[0][1].props.children[0].props.children[2].props)&&Array.isArray(t.children[0][1].props.children[0].props.children[2].props.children)&&(null!==t.children[0][1].props.children[0].props.children[2].props.children[7]&&"object"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7]||"function"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7])&&(null!==t.children[0][1].props.children[0].props.children[2].props.children[7].props&&"object"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props||"function"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props)&&(null!==t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser&&"object"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser||"function"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser)&&"string"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser.screen_name}(t);return function(e){const t=e;return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.children)&&Array.isArray(t.children[0])&&(null!==t.children[0][1]&&"object"==typeof t.children[0][1]||"function"==typeof t.children[0][1])&&(null!==t.children[0][1].props&&"object"==typeof t.children[0][1].props||"function"==typeof t.children[0][1].props)&&Array.isArray(t.children[0][1].props.children)&&(null!==t.children[0][1].props.children[0]&&"object"==typeof t.children[0][1].props.children[0]||"function"==typeof t.children[0][1].props.children[0])&&(null!==t.children[0][1].props.children[0].props&&"object"==typeof t.children[0][1].props.children[0].props||"function"==typeof t.children[0][1].props.children[0].props)&&Array.isArray(t.children[0][1].props.children[0].props.children)&&(null!==t.children[0][1].props.children[0].props.children[1]&&"object"==typeof t.children[0][1].props.children[0].props.children[1]||"function"==typeof t.children[0][1].props.children[0].props.children[1])&&(null!==t.children[0][1].props.children[0].props.children[1].props&&"object"==typeof t.children[0][1].props.children[0].props.children[1].props||"function"==typeof t.children[0][1].props.children[0].props.children[1].props)&&Array.isArray(t.children[0][1].props.children[0].props.children[1].props.children)&&Array.isArray(t.children[0][1].props.children[0].props.children[1].props.children[1])&&(null!==t.children[0][1].props.children[0].props.children[1].props.children[1][2]&&"object"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2]||"function"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2])&&(null!==t.children[0][1].props.children[0].props.children[1].props.children[1][2].props&&"object"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props||"function"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props)&&(null!==t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser&&"object"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser||"function"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser)&&"string"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser.screen_name}(t)&&(r=t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser.screen_name),o&&(r=t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser.screen_name),{isFocalMode:o,isPostedByCurrentUser:e===r}}async clickRetweetButton(e){const t=await(0,i.asyncQuerySelector)("[data-testid='unretweet'], [data-testid='retweet']",this.tweetElement,e);if(!t)throw new Error("Failed to get retweet button of tweet");t.click()}static async clickQuoteButton(e){const t=await(0,i.asyncQuerySelector)(["[data-testid='Dropdown'] [href='/compose/post']","[data-testid='sheetDialog'] [href='/compose/post']"].join(","),document,e);if(!t)throw new Error("Failed to get quote button of tweet");t.click()}static async getTweetTextBox(e){const t="pro.twitter.com"===location.hostname?"[role='dialog'] [data-text='true'], [role='dialog'] textarea[data-testid='tweetTextarea_0']":"[role='dialog'] [data-text='true'], textarea[data-testid='tweetTextarea_0']",r=await(0,i.asyncQuerySelector)(t,document,e);if(!r)throw new Error("Failed to get text box marker of tweet");const n="TEXTAREA"===r.tagName?r:r.parentElement;if(!n)throw new Error("Failed to get text box of tweet");return n}async quoteTweet(e,t=1e3){try{await this.clickRetweetButton(t),await p.clickQuoteButton(t);const r=await p.getTweetTextBox(t);r.innerHTML=e,r.dispatchEvent(new Event("input",{bubbles:!0}))}catch(t){const r=this.props.permalink;open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(`${e}\nhttps://twitter.com${r}`)}`,"_blank")}}}const s={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var l,c=new Uint8Array(16);function d(){if(!l&&!(l="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(c)}for(var h=[],a=0;a<256;++a)h.push((a+256).toString(16).slice(1));const u=function(e,t,r){if(s.randomUUID&&!t&&!e)return s.randomUUID();var n=(e=e||{}).random||(e.rng||d)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var o=0;o<16;++o)t[r+o]=n[o];return t}return function(e,t=0){return(h[e[t+0]]+h[e[t+1]]+h[e[t+2]]+h[e[t+3]]+"-"+h[e[t+4]]+h[e[t+5]]+"-"+h[e[t+6]]+h[e[t+7]]+"-"+h[e[t+8]]+h[e[t+9]]+"-"+h[e[t+10]]+h[e[t+11]]+h[e[t+12]]+h[e[t+13]]+h[e[t+14]]+h[e[t+15]]).toLowerCase()}(n)};class f{OBSERVER_OPTIONS={childList:!0,subtree:!0};onNewTweetCallback=null;onNewProfileCallback=null;constructor(e){const t=`data-twi-ext-checked-${u()}`,r={timeoutMs:1e4,...e},n=new MutationObserver((()=>{if(this.onNewTweetCallback){const e=document.querySelectorAll(`[data-testid="tweet"]:not([${t}])`);for(const r of e)r.setAttribute(t,""),this.onNewTweetCallback(new p(r))}if(this.onNewProfileCallback){const e=document.querySelector(`:not([data-testid="tweet"]) [data-testid="UserName"]:not([${t}])`);e&&(e.setAttribute(t,""),this.onNewProfileCallback(new o(e)))}}));(0,i.asyncQuerySelector)("main",document,r.timeoutMs).then((e=>{if(!e)throw new Error("twi-ext: Failed to get main element");n.observe(e,this.OBSERVER_OPTIONS)})),(0,i.asyncQuerySelector)("#layers",document,r.timeoutMs).then((e=>{if(!e)throw new Error("twi-ext: Failed to get #layers element");n.observe(e,this.OBSERVER_OPTIONS)}))}onNewTweet(e){this.onNewTweetCallback=e}onNewProfile(e){this.onNewProfileCallback=e}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(new(r(146).Timeline)).onNewTweet((e=>{(e=>{const t=e.element.querySelector("[role='group'] a[href$='analytics']");t&&t.parentElement&&(t.href="",t.parentElement.style.display="none");const r=document.querySelector("a[aria-describedby] time");if(r&&r.parentElement&&r.parentElement.parentElement&&r.parentElement.parentElement.parentElement){const e=r.parentElement.parentElement.parentElement.querySelectorAll("div ~ *");for(const t of e)t.style.display="none"}})(e)}))})(); \ No newline at end of file +(()=>{"use strict";var e={531:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function p(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(p,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.asyncQuerySelectorAll=t.asyncQuerySelector=void 0;const n=(e,t)=>new Promise((r=>{const n=e();if(n instanceof Element||n instanceof NodeList&&n.length)return void r(n);let o=null;const i=new MutationObserver((()=>{const t=e();(t instanceof Element||t instanceof NodeList&&t.length)&&(i.disconnect(),o&&clearTimeout(o),r(t))}));o=setTimeout((()=>{i.disconnect(),r(null)}),t),i.observe(document.body,{attributes:!0,childList:!0,subtree:!0})}));t.asyncQuerySelector=(e,...t)=>r(void 0,[e,...t],void 0,(function*(e,t=document,r=500){return yield n((()=>t.querySelector(e)),r)})),t.asyncQuerySelectorAll=(e,...t)=>r(void 0,[e,...t],void 0,(function*(e,t=document,r=500){var o;return null!==(o=yield n((()=>t.querySelectorAll(e)),r))&&void 0!==o?o:document.createDocumentFragment().childNodes}))}},t={};const r=e=>{const t=Object.getOwnPropertyNames(e).filter((e=>e.startsWith("__reactProps$")));return t.length?e[t[0]]:null};class n{profileElement;constructor(e){this.profileElement=e}get props(){const e=r(this.profileElement);if(!function(e){const t=e;return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.children)&&(null!==t.children[0]&&"object"==typeof t.children[0]||"function"==typeof t.children[0])&&(null!==t.children[0].props&&"object"==typeof t.children[0].props||"function"==typeof t.children[0].props)&&Array.isArray(t.children[0].props.children)&&(null!==t.children[0].props.children[1]&&"object"==typeof t.children[0].props.children[1]||"function"==typeof t.children[0].props.children[1])&&(null!==t.children[0].props.children[1].props&&"object"==typeof t.children[0].props.children[1].props||"function"==typeof t.children[0].props.children[1].props)&&(null!==t.children[0].props.children[1].props.user&&"object"==typeof t.children[0].props.children[1].props.user||"function"==typeof t.children[0].props.children[1].props.user)&&(void 0===t.children[0].props.children[1].props.user.possibly_sensitive||null===t.children[0].props.children[1].props.user.possibly_sensitive||!1===t.children[0].props.children[1].props.user.possibly_sensitive||!0===t.children[0].props.children[1].props.user.possibly_sensitive)&&"string"==typeof t.children[0].props.children[1].props.user.screen_name&&(""===t.children[0].props.children[1].props.user.profile_interstitial_type||"sensitive_media"===t.children[0].props.children[1].props.user.profile_interstitial_type||"fake_account"===t.children[0].props.children[1].props.user.profile_interstitial_type||"offensive_profile_content"===t.children[0].props.children[1].props.user.profile_interstitial_type||"timeout"===t.children[0].props.children[1].props.user.profile_interstitial_type)&&Array.isArray(t.children[0].props.children[1].props.user.withheld_in_countries)&&t.children[0].props.children[1].props.user.withheld_in_countries.every((e=>"string"==typeof e))}(e))throw new Error("Failed to get React props of profile");return e.children[0].props.children[1].props.user}}var o=function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(531);class i{tweetElement;constructor(e){this.tweetElement=e}getMenuBar(){const e=this.tweetElement.querySelector("div[role='group'][id]");if(!e)throw new Error("Failed to get menu bar of tweet");return e}get element(){return this.tweetElement}get props(){const e=r(this.getMenuBar());if(!function(e){const t=e;return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.children)&&(null!==t.children[1]&&"object"==typeof t.children[1]||"function"==typeof t.children[1])&&(null!==t.children[1].props&&"object"==typeof t.children[1].props||"function"==typeof t.children[1].props)&&(null!==t.children[1].props.retweetWithCommentLink&&"object"==typeof t.children[1].props.retweetWithCommentLink||"function"==typeof t.children[1].props.retweetWithCommentLink)&&(null!==t.children[1].props.retweetWithCommentLink.state&&"object"==typeof t.children[1].props.retweetWithCommentLink.state||"function"==typeof t.children[1].props.retweetWithCommentLink.state)&&(null!==t.children[1].props.retweetWithCommentLink.state.quotedStatus&&"object"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus||"function"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus)&&(void 0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive||null===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive||!1===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive||!0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive)&&(void 0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive_editable||null===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive_editable||!1===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive_editable||!0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.possibly_sensitive_editable)&&"string"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus.permalink&&(null!==t.children[1].props.retweetWithCommentLink.state.quotedStatus.user&&"object"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus.user||"function"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus.user)&&(void 0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.possibly_sensitive||null===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.possibly_sensitive||!1===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.possibly_sensitive||!0===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.possibly_sensitive)&&"string"==typeof t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.screen_name&&(""===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type||"sensitive_media"===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type||"fake_account"===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type||"offensive_profile_content"===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type||"timeout"===t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.profile_interstitial_type)&&Array.isArray(t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.withheld_in_countries)&&t.children[1].props.retweetWithCommentLink.state.quotedStatus.user.withheld_in_countries.every((e=>"string"==typeof e))}(e))throw new Error("Failed to get React props of tweet");return e.children[1].props.retweetWithCommentLink.state.quotedStatus}get metadata(){const e=this.props.user.screen_name,t=r(this.element);if(!t)throw new Error("Failed to get React props of tweet");let n=null;const o=function(e){const t=e;return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.children)&&Array.isArray(t.children[0])&&(null!==t.children[0][1]&&"object"==typeof t.children[0][1]||"function"==typeof t.children[0][1])&&(null!==t.children[0][1].props&&"object"==typeof t.children[0][1].props||"function"==typeof t.children[0][1].props)&&Array.isArray(t.children[0][1].props.children)&&(null!==t.children[0][1].props.children[0]&&"object"==typeof t.children[0][1].props.children[0]||"function"==typeof t.children[0][1].props.children[0])&&(null!==t.children[0][1].props.children[0].props&&"object"==typeof t.children[0][1].props.children[0].props||"function"==typeof t.children[0][1].props.children[0].props)&&Array.isArray(t.children[0][1].props.children[0].props.children)&&(null!==t.children[0][1].props.children[0].props.children[2]&&"object"==typeof t.children[0][1].props.children[0].props.children[2]||"function"==typeof t.children[0][1].props.children[0].props.children[2])&&(null!==t.children[0][1].props.children[0].props.children[2].props&&"object"==typeof t.children[0][1].props.children[0].props.children[2].props||"function"==typeof t.children[0][1].props.children[0].props.children[2].props)&&Array.isArray(t.children[0][1].props.children[0].props.children[2].props.children)&&(null!==t.children[0][1].props.children[0].props.children[2].props.children[7]&&"object"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7]||"function"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7])&&(null!==t.children[0][1].props.children[0].props.children[2].props.children[7].props&&"object"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props||"function"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props)&&(null!==t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser&&"object"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser||"function"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser)&&"string"==typeof t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser.screen_name}(t);return function(e){const t=e;return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.children)&&Array.isArray(t.children[0])&&(null!==t.children[0][1]&&"object"==typeof t.children[0][1]||"function"==typeof t.children[0][1])&&(null!==t.children[0][1].props&&"object"==typeof t.children[0][1].props||"function"==typeof t.children[0][1].props)&&Array.isArray(t.children[0][1].props.children)&&(null!==t.children[0][1].props.children[0]&&"object"==typeof t.children[0][1].props.children[0]||"function"==typeof t.children[0][1].props.children[0])&&(null!==t.children[0][1].props.children[0].props&&"object"==typeof t.children[0][1].props.children[0].props||"function"==typeof t.children[0][1].props.children[0].props)&&Array.isArray(t.children[0][1].props.children[0].props.children)&&(null!==t.children[0][1].props.children[0].props.children[1]&&"object"==typeof t.children[0][1].props.children[0].props.children[1]||"function"==typeof t.children[0][1].props.children[0].props.children[1])&&(null!==t.children[0][1].props.children[0].props.children[1].props&&"object"==typeof t.children[0][1].props.children[0].props.children[1].props||"function"==typeof t.children[0][1].props.children[0].props.children[1].props)&&Array.isArray(t.children[0][1].props.children[0].props.children[1].props.children)&&Array.isArray(t.children[0][1].props.children[0].props.children[1].props.children[1])&&(null!==t.children[0][1].props.children[0].props.children[1].props.children[1][2]&&"object"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2]||"function"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2])&&(null!==t.children[0][1].props.children[0].props.children[1].props.children[1][2].props&&"object"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props||"function"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props)&&(null!==t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser&&"object"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser||"function"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser)&&"string"==typeof t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser.screen_name}(t)&&(n=t.children[0][1].props.children[0].props.children[1].props.children[1][2].props.loggedInUser.screen_name),o&&(n=t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser.screen_name),{isFocalMode:o,isPostedByCurrentUser:e===n}}async clickRetweetButton(e){const t=await(0,o.asyncQuerySelector)("[data-testid='unretweet'], [data-testid='retweet']",this.tweetElement,e);if(!t)throw new Error("Failed to get retweet button of tweet");t.click()}static async clickQuoteButton(e){const t=await(0,o.asyncQuerySelector)(["[data-testid='Dropdown'] [href='/compose/post']","[data-testid='sheetDialog'] [href='/compose/post']"].join(","),document,e);if(!t)throw new Error("Failed to get quote button of tweet");t.click()}static async getTweetTextBox(e){const t="pro.twitter.com"===location.hostname?"[role='dialog'] [data-text='true'], [role='dialog'] textarea[data-testid='tweetTextarea_0']":"[role='dialog'] [data-text='true'], textarea[data-testid='tweetTextarea_0']",r=await(0,o.asyncQuerySelector)(t,document,e);if(!r)throw new Error("Failed to get text box marker of tweet");const n="TEXTAREA"===r.tagName?r:r.parentElement;if(!n)throw new Error("Failed to get text box of tweet");return n}async quoteTweet(e,t=1e3){try{await this.clickRetweetButton(t),await i.clickQuoteButton(t);const r=await i.getTweetTextBox(t);r.innerHTML=e,r.dispatchEvent(new Event("input",{bubbles:!0}))}catch{const t=this.props.permalink;open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(`${e}\nhttps://twitter.com${t}`)}`,"_blank")}}}const p={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var s,l=new Uint8Array(16);function c(){if(!s&&!(s="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return s(l)}for(var d=[],h=0;h<256;++h)d.push((h+256).toString(16).slice(1));const a=function(e,t,r){if(p.randomUUID&&!t&&!e)return p.randomUUID();var n=(e=e||{}).random||(e.rng||c)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var o=0;o<16;++o)t[r+o]=n[o];return t}return function(e,t=0){return(d[e[t+0]]+d[e[t+1]]+d[e[t+2]]+d[e[t+3]]+"-"+d[e[t+4]]+d[e[t+5]]+"-"+d[e[t+6]]+d[e[t+7]]+"-"+d[e[t+8]]+d[e[t+9]]+"-"+d[e[t+10]]+d[e[t+11]]+d[e[t+12]]+d[e[t+13]]+d[e[t+14]]+d[e[t+15]]).toLowerCase()}(n)};(new class{OBSERVER_OPTIONS={childList:!0,subtree:!0};onNewTweetCallback=null;onNewProfileCallback=null;constructor(e){const t=`data-twi-ext-checked-${a()}`,r={timeoutMs:1e4,...e},p=new MutationObserver((()=>{if(this.onNewTweetCallback){const e=document.querySelectorAll(`[data-testid="tweet"]:not([${t}])`);for(const r of e)r.setAttribute(t,""),this.onNewTweetCallback(new i(r))}if(this.onNewProfileCallback){const e=document.querySelector(`:not([data-testid="tweet"]) [data-testid="UserName"]:not([${t}])`);e&&(e.setAttribute(t,""),this.onNewProfileCallback(new n(e)))}}));(0,o.asyncQuerySelector)("main",document,r.timeoutMs).then((e=>{if(!e)throw new Error("twi-ext: Failed to get main element");p.observe(e,this.OBSERVER_OPTIONS)})),(0,o.asyncQuerySelector)("#layers",document,r.timeoutMs).then((e=>{if(!e)throw new Error("twi-ext: Failed to get #layers element");p.observe(e,this.OBSERVER_OPTIONS)}))}onNewTweet(e){this.onNewTweetCallback=e}onNewProfile(e){this.onNewProfileCallback=e}}).onNewTweet((e=>{(e=>{const t=e.element.querySelector("[role='group'] a[href$='analytics']");t?.parentElement&&(t.href="",t.parentElement.style.display="none");const r=document.querySelector("a[aria-describedby] time");if(r?.parentElement?.parentElement?.parentElement){const e=r.parentElement.parentElement.parentElement.querySelectorAll("div ~ *");for(const t of e)t.style.display="none"}})(e)}))})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index eb5c1d8..c4073ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hide-impression", - "version": "2.1.1", + "version": "2.1.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "hide-impression", - "version": "2.1.1", + "version": "2.1.2", "license": "MIT", "dependencies": { "@robot-inventor/eslint-config": "^4.0.0", diff --git a/package.json b/package.json index 1cbb642..b175452 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hide-impression", - "version": "2.1.1", + "version": "2.1.2", "description": "Browser extension to hide the number of Twitter impressions", "main": "index.js", "scripts": {