-
-
Save if1live/bc4750c0d4585789b66d899129ecb9ad to your computer and use it in GitHub Desktop.
Force enable cramming (280 character tweets) on Twitter. NOTE: Stops working when you switch pages, refresh to fix. https://twitter.com/Prof9/status/912859110776950784
This file contains 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
// ==UserScript== | |
// @name Twitter Cramming | |
// @description Force enable cramming (280 character tweets) on Twitter | |
// @author Prof. 9 | |
// @version 0.2 | |
// @match https://twitter.com/* | |
// @run-at document-idle | |
// @namespace prof9.twittercramming | |
// ==/UserScript== | |
var initDataInput = document.getElementById('init-data'); | |
var initData = JSON.parse(initDataInput.value); | |
initData.deciders.cramming_feature_enabled = true; | |
initData.deciders.cramming_ui_enabled = true; | |
initDataInput.value = JSON.stringify(initData); | |
// for CJK and etc | |
function getTwitterTextOptions(form) { | |
var keys = Object.keys(form); | |
for(var i = 0 ; i < keys.length ; i++) { | |
if(keys[i].startsWith('jQuery')) { | |
var jqc = form[keys[i]]; | |
return jqc.events.uiTextChanged[0].handler.context.attr.twitterTextOptions; | |
} | |
} | |
return null; | |
} | |
function modifyTextWeight(form) { | |
if(!form) { | |
return false; | |
} | |
var opt = getTwitterTextOptions(form); | |
//alert(JSON.stringify(opt)); | |
if(!opt) { | |
return false; | |
} | |
// version: "default", | |
// max_tweet_length: 140, | |
// scale: 100, | |
// default_weight: 100, | |
// short_url_length: 23, | |
// short_url_length_https: 23 | |
if(opt.version === 'default') { | |
opt.max_tweet_length = 280; | |
return true; | |
} | |
// version: "cramming", | |
// max_tweet_length: 280, | |
// default_weight: 200, | |
// ranges: [{ | |
// start: 0, | |
// end: 4351, | |
// weight: 100 | |
// }, { | |
// start: 4352, | |
// end: 65535, | |
// weight: 200 | |
// }] | |
if(opt.version === 'cramming') { | |
opt.ranges[1].weight = 100; | |
opt.default_weight = 100; | |
return true; | |
} | |
return false; | |
} | |
document.onreadystatechange = function() { | |
function check(form) { | |
var success = modifyTextWeight(form); | |
if(!success) { | |
setTimeout(function() { check(form); }, 100); | |
} | |
} | |
var forms = document.querySelectorAll('form.tweet-form'); | |
for(var i = 0 ; i < forms.length ; i++) { | |
check(forms[i]); | |
} | |
}; |
Vai tomar no cú, vocês estão de palhaçada com a nossa cara. Essa porra não funciona nem um pouco.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
유저스크립트를 여려워하는 사람들이 많아서 브라우저 플러그인으로 감싸려고 합니다. 혹시 코드 라이센스 명시해주실 수 있으신가요?다시 서버에서 막혀서 그만두기로 했습니다.Reference