From 8b5a62eaa028ebd07c105f6bd2892fdad83683b7 Mon Sep 17 00:00:00 2001 From: Robot-Inventor <30.keita@gmail.com> Date: Tue, 16 Apr 2024 12:50:20 +0900 Subject: [PATCH] 2.0.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 f75f57e..c50806f 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.0.1 +// @version 2.0.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/* @@ -13,4 +13,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||n instanceof NodeList&&n.length)return void r(n);let o=null;const i=new MutationObserver((()=>{const t=e();t&&(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}))},272:(e,t,r)=>{r.r(t),r.d(t,{Timeline:()=>a,Tweet:()=>i});var n=r(531);const o=e=>{const t=Object.getOwnPropertyNames(e).filter((e=>e.startsWith("__reactProps$")));return t.length?e[t[0]]:null};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=o(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=o(this.element);if(!t)throw new Error("Failed to get React props of tweet");let r=null;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),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)&&(r=t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser.screen_name),{isPostedByCurrentUser:e===r}}async clickRetweetButton(e){const t=await(0,n.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,n.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,n.asyncQuerySelector)(t,document,e);if(!r)throw new Error("Failed to get text box marker of tweet");const o="TEXTAREA"===r.tagName?r:r.parentElement;if(!o)throw new Error("Failed to get text box of tweet");return o}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(t){const r=this.props.permalink;open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(`${e}\nhttps://twitter.com${r}`)}`,"_blank")}}}const p={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let s;const l=new Uint8Array(16);function c(){if(!s&&(s="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!s))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return s(l)}const d=[];for(let e=0;e<256;++e)d.push((e+256).toString(16).slice(1));const h=function(e,t,r){if(p.randomUUID&&!t&&!e)return p.randomUUID();const 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(let e=0;e<16;++e)t[r+e]=n[e];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]]}(n)};class a{OBSERVER_OPTIONS={childList:!0,subtree:!0};onNewTweetCallback=null;constructor(e){const t=`twi-ext-checked-${h()}`,r={timeoutMs:1e4,...e},o=new MutationObserver((()=>{if(!this.onNewTweetCallback)return;const e=document.querySelectorAll(`[data-testid="tweet"]:not([${t}])`);if(e.length)for(const r of e)r.setAttribute(t,""),this.onNewTweetCallback(new i(r))}));(0,n.asyncQuerySelector)("main",document,r.timeoutMs).then((e=>{if(!e)throw new Error("twi-ext: Failed to get main element");o.observe(e,this.OBSERVER_OPTIONS)}))}onNewTweet(e){this.onNewTweetCallback=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(272).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}))},272:(e,t,r)=>{r.r(t),r.d(t,{Timeline:()=>a,Tweet:()=>i});var n=r(531);const o=e=>{const t=Object.getOwnPropertyNames(e).filter((e=>e.startsWith("__reactProps$")));return t.length?e[t[0]]:null};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=o(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=o(this.element);if(!t)throw new Error("Failed to get React props of tweet");let r=null;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),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)&&(r=t.children[0][1].props.children[0].props.children[2].props.children[7].props.loggedInUser.screen_name),{isPostedByCurrentUser:e===r}}async clickRetweetButton(e){const t=await(0,n.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,n.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,n.asyncQuerySelector)(t,document,e);if(!r)throw new Error("Failed to get text box marker of tweet");const o="TEXTAREA"===r.tagName?r:r.parentElement;if(!o)throw new Error("Failed to get text box of tweet");return o}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(t){const r=this.props.permalink;open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(`${e}\nhttps://twitter.com${r}`)}`,"_blank")}}}const p={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let s;const l=new Uint8Array(16);function c(){if(!s&&(s="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!s))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return s(l)}const d=[];for(let e=0;e<256;++e)d.push((e+256).toString(16).slice(1));const h=function(e,t,r){if(p.randomUUID&&!t&&!e)return p.randomUUID();const 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(let e=0;e<16;++e)t[r+e]=n[e];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]]}(n)};class a{OBSERVER_OPTIONS={childList:!0,subtree:!0};onNewTweetCallback=null;constructor(e){const t=`twi-ext-checked-${h()}`,r={timeoutMs:1e4,...e},o=new MutationObserver((()=>{if(!this.onNewTweetCallback)return;const e=document.querySelectorAll(`[data-testid="tweet"]:not([${t}])`);if(e.length)for(const r of e)r.setAttribute(t,""),this.onNewTweetCallback(new i(r))}));(0,n.asyncQuerySelector)("main",document,r.timeoutMs).then((e=>{if(!e)throw new Error("twi-ext: Failed to get main element");o.observe(e,this.OBSERVER_OPTIONS)})),(0,n.asyncQuerySelector)("#layers",document,r.timeoutMs).then((e=>{if(!e)throw new Error("twi-ext: Failed to get #layers element");o.observe(e,this.OBSERVER_OPTIONS)}))}onNewTweet(e){this.onNewTweetCallback=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(272).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 diff --git a/package-lock.json b/package-lock.json index 36fbfd8..6e91e65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hide-impression", - "version": "2.0.1", + "version": "2.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "hide-impression", - "version": "2.0.1", + "version": "2.0.2", "license": "MIT", "dependencies": { "@robot-inventor/eslint-config": "^0.1.1", diff --git a/package.json b/package.json index a6648f9..0c6830f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hide-impression", - "version": "2.0.1", + "version": "2.0.2", "description": "Browser extension to hide the number of Twitter impressions", "main": "index.js", "scripts": {