A place to cache linked articles (think custom and personal wayback machine)
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

index.md 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. title: Write-only Twitter
  2. url: https://laurakalbag.com/write-only-twitter/
  3. hash_url: 1fdec7eb6b2c3d889cbd789de3fb1d1d
  4. <p>A couple of weeks ago, <a href="https://ar.al">Aral</a> asked me if I could write a user stylesheet for web browsers to make Twitter nothing but a compose box.</p>
  5. <p><a href="#how-the-stylesheet-works">Jump straight to how it works</a></p>
  6. <p>I totally get it. <a href="/whats-wrong-with-twitter/">Twitter sucks your time and soul</a>. But sometimes you need to use it to share what you’re working on, or promote events. Essentially, you want to use Twitter but you don’t want it to use you. The way to do this is to hide every part of Twitter’s interface that doesn’t help you compose a tweet, or otherwise likely to distract or derail you.</p>
  7. <h2 id="the-power-of-css-pseudo-classes">The power of CSS pseudo classes</h2>
  8. <p>As part of my work on <a href="https://better.fyi/trackers/">Better’s blocking rules</a>, I sometimes have to hide parts of the page using CSS. Hiding ads isn’t really Better’s purpose, we try to block the tracking and behavioural advertising scripts before they put anything on the page. But occasionally, sites have rolled their own obnoxious first-party targeted ad system that is inseparable from the rest of their site’s functionality. On such occasions, I roll up my sleeves, and get my <a href="https://css-tricks.com/pseudo-class-selectors/">pseudo CSS selectors</a> out to set these elements to <code>display: none</code>. Because, of course, these sites design their HTML and CSS to avoid blockers like Better.</p>
  9. <h3 id="the-problem-with-user-stylesheets">The problem with user stylesheets</h3>
  10. <p>Hiding parts of Twitter’s interface is a similar problem. Luckily, a lot of Twitter’s interface has semantic naming (amongst the gazillion nested <code>div</code>s and robot-generated CSS classes) for accessibility purposes, so it’s simple enough to hook into these elements for a user stylesheet. The problem with user stylesheets is that they’re a blunt instrument, aimed at making global changes across every site you visit. Really useful for making font sizes big on every site you visit, but if you use it to hide any element with the class of “<code>timeline</code>”, chances are you’ll break a lot of websites you visit.</p>
  11. <h3 id="a-solution-to-target-specific-websites">A solution to target specific websites</h3>
  12. <p>My solution was to chain what I suspect are fairly unique element selectors in a likely unique sequence, ensuring that these rules will only apply to twitter.com, even though the stylesheet will be used on every site visited.</p>
  13. <div class="highlight"><pre class="chroma"><code class="language-css" data-lang="css"><span class="c">/* Hide the Home timeline and Explore timeline */</span>
  14. <span class="nt">div</span><span class="o">[</span><span class="nt">data-at-shortcutkeys</span><span class="o">]</span> <span class="nt">header</span><span class="o">[</span><span class="nt">role</span><span class="o">=</span><span class="s2">"banner"</span><span class="o">]</span> <span class="o">+</span> <span class="nt">main</span><span class="o">[</span><span class="nt">role</span><span class="o">=</span><span class="s2">"main"</span><span class="o">]</span> <span class="nt">div</span><span class="o">[</span><span class="nt">aria-label</span><span class="o">=</span><span class="s2">"Timeline: Your Home Timeline"</span><span class="o">],</span>
  15. <span class="nt">div</span><span class="o">[</span><span class="nt">data-at-shortcutkeys</span><span class="o">]</span> <span class="nt">header</span><span class="o">[</span><span class="nt">role</span><span class="o">=</span><span class="s2">"banner"</span><span class="o">]</span> <span class="o">+</span> <span class="nt">main</span><span class="o">[</span><span class="nt">role</span><span class="o">=</span><span class="s2">"main"</span><span class="o">]</span> <span class="nt">div</span><span class="o">[</span><span class="nt">aria-label</span><span class="o">=</span><span class="s2">"Timeline: Explore"</span><span class="o">]</span> <span class="p">{</span>
  16. <span class="k">display</span><span class="p">:</span> <span class="kc">none</span> <span class="cp">!important</span><span class="p">;</span>
  17. <span class="p">}</span>
  18. </code></pre></div><p>As you can tell from the selectors I’ve used, it is fragile as anything. As soon as Twitter decides to change the <code>aria-label</code> for its home timeline, the stylesheet will no longer effectively hide the home timeline. But, as with a lot of Better’s blocking rules, this is a balance between using a fragile rule that works against a big corporation that tends to be pretty slow in rolling out changes to its interface.</p>
  19. <p>After a couple of weeks of using this stylesheet in my primary browser and not noticing any issues with other sites, I’m fairly confident in sharing this stylesheet with anyone else who might find it useful.</p>
  20. <h2 id="how-the-stylesheet-works">How the stylesheet works</h2>
  21. <p>I ended up creating two stylesheets, one for Aral’s way of working (<code>write-only.css</code>), and one for my way of working (<code>read-some.css</code>).</p>
  22. <p><a href="https://source.small-tech.org/laura/write-only-twitter/-/blob/master/write-only.css"><code>write-only.css</code></a> is a user stylesheet for the browser that hides absolutely everything except the Home feed compose box on Twitter.</p>
  23. <figure>
  24. <img class="landscape" sizes="(min-width: 1380px) 750px, (min-width: 820px) 719px, (min-width: 740px) calc(-33.33vw + 875px), (min-width: 340px) calc(92.63vw - 39px), calc(100vw - 32px)" srcset="/write-only-twitter/write-only-twitter/social_hu3843e09fa51a0152293fbbf1ad71c1cb_33928_300x0_resize_mitchellnetravali_2.png 300w,/write-only-twitter/write-only-twitter/social_hu3843e09fa51a0152293fbbf1ad71c1cb_33928_500x0_resize_mitchellnetravali_2.png 500w,/write-only-twitter/write-only-twitter/social_hu3843e09fa51a0152293fbbf1ad71c1cb_33928_800x0_resize_mitchellnetravali_2.png 800w,/write-only-twitter/write-only-twitter/social.png 1118w" src="social.png" alt="Web page showing just Twitter’s compose box, no other parts of Twitter’s interface.">
  25. <figcaption>
  26. <p><code>write-only.css</code> in action.</p>
  27. </figcaption>
  28. </figure>
  29. <p>My Twitter use varies, particularly as I sometimes use it for Better support, so I need to be able to access a bit more of Twitter’s interface.</p>
  30. <p><a href=""><code>read-some.css</code></a> is a user stylesheet for the browser that hides:</p>
  31. <ul>
  32. <li>Home timeline</li>
  33. <li>Explore timeline</li>
  34. <li>List timelines</li>
  35. </ul>
  36. <p>but keeps:</p>
  37. <ul>
  38. <li>Mentions</li>
  39. <li>Messages</li>
  40. <li>Settings etc</li>
  41. </ul>
  42. <p>And let me tell you, having this stylesheet on my desktop Safari for the last couple of weeks has made a huge difference. Now I can check our @mentions without getting further distracted. Even when my muscle memory types “twitter.com” when I’m procrastinating or seeking distraction, the page loads so minimally, I take one look at it and close the tab. It no longer appears in my “Frequently Visited” sites!</p>
  43. <figure>
  44. <img class="landscape" sizes="(min-width: 1380px) 750px, (min-width: 820px) 719px, (min-width: 740px) calc(-33.33vw + 875px), (min-width: 340px) calc(92.63vw - 39px), calc(100vw - 32px)" srcset="/write-only-twitter/write-only-twitter/read-some_hu1fd5ca1b59b76b36250d12d5d1634087_45368_300x0_resize_mitchellnetravali_2.png 300w,/write-only-twitter/write-only-twitter/read-some_hu1fd5ca1b59b76b36250d12d5d1634087_45368_500x0_resize_mitchellnetravali_2.png 500w,/write-only-twitter/write-only-twitter/read-some_hu1fd5ca1b59b76b36250d12d5d1634087_45368_800x0_resize_mitchellnetravali_2.png 800w,/write-only-twitter/write-only-twitter/read-some.png 1118w" src="read-some.png" alt="Web page showing Twitter’s interface without the timeline of tweets or What’s Happening sidebar.">
  45. <figcaption>
  46. <p><code>read-some.css</code> in action.</p>
  47. </figcaption>
  48. </figure>
  49. <h2 id="where-to-find-the-stylesheets">Where to find the stylesheets</h2>
  50. <p>You can <a href="https://source.small-tech.org/laura/write-only-twitter">download the Write-Only Twitter stylesheets and find out more about them on our Small Tech repository</a>. I’ll update them when needed. There’s not instructions for every browser in there, but it shouldn’t be too hard for you to find that information if you need it. Personally I recommend Safari for everyday browsing as you can use <a href="https://better.fyi">Better Blocker</a> to block trackers while you browse 😉</p>