Skip to content

Instantly share code, notes, and snippets.

@pixeldesu
Last active March 27, 2017 13:54
Show Gist options
  • Save pixeldesu/24980c009114f0ee5d6b45892e355745 to your computer and use it in GitHub Desktop.
Save pixeldesu/24980c009114f0ee5d6b45892e355745 to your computer and use it in GitHub Desktop.
Add Favstar action to Tweet actions
// This replaces the template for the dropdown menu contents with a new copy that includes a Favstar link to the specific status.
// For some reason, this sometimes works and sometimes doesn't. This can also be done way cleaner,
// this code is just some kind of proof-of-concept.
TD_mustaches["menus/actions.mustache"] = TD_mustaches["menus/actions.mustache"].replace(
'<ul> {{#chirp}} {{#user}}{{^isProtected}} <li class="is-selectable"><a href="#" data-action="embed">{{_i}}Embed this Tweet{{/i}}</a></li> <li class="is-selectable"><a href="#" data-action="reference-to">{{_i}}Copy link to this Tweet{{/i}}</a></li> <li class="is-selectable"><a href="#" data-action="message-to">{{_i}}Share via Direct Message{{/i}}</a></li> <li class="is-selectable"><a href="#" data-action="email">{{_i}}Share via Email{{/i}}</a></li> <li class="drp-h-divider"></li> {{/isProtected}}{{/user}} {{/chirp}} {{#user}} <li class="is-selectable"><a href="#" data-action="mention" class="txt-ellipsis">{{_i}}Tweet to @{{screenName}}{{/i}}</a></li> {{> menus/follow_menuitem }} {{#showFavorite}} <li class="is-selectable"> <a href="#" data-action="favoriteOrUnfavorite"> {{_i}}Like from accounts…{{/i}} </a> </li> {{/showFavorite}} <li class="is-selectable"><a href="#" data-action="message">{{_i}}Send a Direct Message{{/i}}</a></li> <li class="is-selectable"><a href="#" data-action="lists">{{_i}}Add or remove from lists…{{/i}}</a></li> {{#chirp}}{{#user}}{{^isProtected}} <li class="feature-customtimelines is-selectable"><a href="#" data-action="customtimelines">{{_i}}Add to collection…{{/i}}</a></li> {{/isProtected}}{{/user}}{{/chirp}} {{/user}} {{#user}} {{^isMe}} <li class="drp-h-divider"></li> {{#chirp}} {{#hasMedia}} <li class="is-selectable"> <a class="js-flag-media-link {{#isFlagged}}is-hidden{{/isFlagged}}" href="#" data-action="flag-media">{{_i}}Flag media{{/i}}</a> <a class="js-flag-more-info-link {{^isFlagged}}is-hidden{{/isFlagged}}" href="https://support.twitter.com/articles/20069937" data-action target="_blank" rel="url">{{_i}}Flagged (learn more){{/i}}</a> </li> {{/hasMedia}} {{/chirp}} {{^isMuted}} <li class="is-selectable"><a href="#" data-action="mute" class="txt-ellipsis">{{_i}}Mute @{{screenName}}{{/i}}</a></li> {{/isMuted}} {{#isMuted}} <li class="is-selectable"><a href="#" data-action="unmute" class="txt-ellipsis">{{_i}}Unmute @{{screenName}}{{/i}}</a></li> {{/isMuted}} <li class="is-selectable"><a href="#" data-action="block" class="txt-ellipsis">{{_i}}Block @{{screenName}}{{/i}}</a></li> {{#chirp}} <li class="is-selectable"><a href="#" data-action="report-tweet" class="txt-ellipsis">{{_i}}Report Tweet{{/i}}</a></li> {{/chirp}} {{^chirp}} <li class="is-selectable"><a href="#" class="txt-ellipsis" data-action="report-spam">{{_i}}Report @{{screenName}}{{/i}}</a></li> {{/chirp}} {{/isMe}} {{/user}} {{#chirp}} {{#isTranslatable}} <li class="drp-h-divider"></li> <li class="is-selectable"><a href="#" data-action="translate">{{_i}}Translate this Tweet{{/i}}</a></li> {{/isTranslatable}} {{#isRetweeted}} <li class="drp-h-divider"></li> <li class="is-selectable"><a href="#" data-action="undo-retweet">{{_i}}Undo Retweet{{/i}}</a></li> {{/isRetweeted}} {{#isOwnChirp}} {{^isRetweeted}} <li class="drp-h-divider"></li> <li class="is-selectable"><a href="#" data-action="destroy">{{_i}}Delete{{/i}}</a></li> {{/isRetweeted}} {{/isOwnChirp}} {{/chirp}} </ul>', '<ul> {{#chirp}} {{#user}}{{^isProtected}} <li class="is-selectable"><a href="#" data-action="embed">{{_i}}Embed this Tweet{{/i}}</a></li> <li class="is-selectable"><a href="#" data-action="reference-to">{{_i}}Copy link to this Tweet{{/i}}</a></li> <li class="is-selectable"><a href="#" data-action="message-to">{{_i}}Share via Direct Message{{/i}}</a></li> <li class="is-selectable"><a href="#" data-action="email">{{_i}}Share via Email{{/i}}</a></li> <li class="drp-h-divider"></li> {{/isProtected}}{{/user}} {{/chirp}} {{#user}} <li class="is-selectable"><a href="#" data-action="mention" class="txt-ellipsis">{{_i}}Tweet to @{{screenName}}{{/i}}</a></li> {{> menus/follow_menuitem }} {{#showFavorite}} <li class="is-selectable"> <a href="#" data-action="favoriteOrUnfavorite"> {{_i}}Like from accounts…{{/i}} </a> </li> {{/showFavorite}} <li class="is-selectable"><a href="#" data-action="message">{{_i}}Send a Direct Message{{/i}}</a></li> <li class="is-selectable"><a href="#" data-action="lists">{{_i}}Add or remove from lists…{{/i}}</a></li> {{#chirp}}{{#user}}{{^isProtected}} <li class="feature-customtimelines is-selectable"><a href="#" data-action="customtimelines">{{_i}}Add to collection…{{/i}}</a></li> {{/isProtected}}{{/user}}{{/chirp}} {{/user}} <li class="feature-customtimelines is-selectable"><a href="https://favstar.fm/users/{{user.screenName}}/status/{{chirp.id}}" target="_blank" data-action="favstar">{{_i}}Show in Favstar{{/i}}</a></li> {{#user}} {{^isMe}} <li class="drp-h-divider"></li> {{#chirp}} {{#hasMedia}} <li class="is-selectable"> <a class="js-flag-media-link {{#isFlagged}}is-hidden{{/isFlagged}}" href="#" data-action="flag-media">{{_i}}Flag media{{/i}}</a> <a class="js-flag-more-info-link {{^isFlagged}}is-hidden{{/isFlagged}}" href="https://support.twitter.com/articles/20069937" data-action target="_blank" rel="url">{{_i}}Flagged (learn more){{/i}}</a> </li> {{/hasMedia}} {{/chirp}} {{^isMuted}} <li class="is-selectable"><a href="#" data-action="mute" class="txt-ellipsis">{{_i}}Mute @{{screenName}}{{/i}}</a></li> {{/isMuted}} {{#isMuted}} <li class="is-selectable"><a href="#" data-action="unmute" class="txt-ellipsis">{{_i}}Unmute @{{screenName}}{{/i}}</a></li> {{/isMuted}} <li class="is-selectable"><a href="#" data-action="block" class="txt-ellipsis">{{_i}}Block @{{screenName}}{{/i}}</a></li> {{#chirp}} <li class="is-selectable"><a href="#" data-action="report-tweet" class="txt-ellipsis">{{_i}}Report Tweet{{/i}}</a></li> {{/chirp}} {{^chirp}} <li class="is-selectable"><a href="#" class="txt-ellipsis" data-action="report-spam">{{_i}}Report @{{screenName}}{{/i}}</a></li> {{/chirp}} {{/isMe}} {{/user}} {{#chirp}} {{#isTranslatable}} <li class="drp-h-divider"></li> <li class="is-selectable"><a href="#" data-action="translate">{{_i}}Translate this Tweet{{/i}}</a></li> {{/isTranslatable}} {{#isRetweeted}} <li class="drp-h-divider"></li> <li class="is-selectable"><a href="#" data-action="undo-retweet">{{_i}}Undo Retweet{{/i}}</a></li> {{/isRetweeted}} {{#isOwnChirp}} {{^isRetweeted}} <li class="drp-h-divider"></li> <li class="is-selectable"><a href="#" data-action="destroy">{{_i}}Delete{{/i}}</a></li> {{/isRetweeted}} {{/isOwnChirp}} {{/chirp}} </ul>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment