Created
June 18, 2012 22:27
-
-
Save legumbre/2951132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
mobile twitter mode | |
- adds rel="next" to the "Load older tweets" button | |
*/ | |
require ("content-buffer.js"); | |
define_page_mode("mobile_twitter_mode", | |
build_url_regexp($domain = "mobile.twitter", | |
$allow_www = true, | |
$tlds = ["com"]) | |
, | |
function enable (buffer) { | |
if (buffer.browser.webProgress.isLoadingDocument) | |
add_hook.call(buffer, "buffer_loaded_hook", twitter_when_loaded); | |
else | |
/* call it right now in case the page-mode | |
* document is already loaded (ie, someone M-x | |
* mobile-twitter-mode manually) */ | |
twitter_when_loaded(buffer); | |
} | |
, | |
function disable (buffer) { | |
// unregister hooks | |
remove_hook.call(buffer, "buffer_loaded_hook", twitter_when_loaded); | |
}, | |
$display_name = "Mobile Twitter", | |
$doc = "Twitter page-mode for mobile.twitter.com"); | |
page_mode_activate(mobile_twitter_mode); | |
function twitter_when_loaded (buffer) { | |
// add rel="next" to the "Load older tweets" link | |
var moreTweets = buffer.document.querySelector('div.w-button-more a'); | |
if (moreTweets) { | |
moreTweets.setAttribute('rel', 'next'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment