Created
May 28, 2010 12:43
-
-
Save mooz/417108 to your computer and use it in GitHub Desktop.
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 OAuth Caution | |
// @namespace http://github.com/mooz/ | |
// @description Display caution when application requests a 'write' access | |
// @include http://twitter.com/oauth/authorize?* | |
// @include http://twitter.com/oauth/authenticate?* | |
// @include https://twitter.com/oauth/authorize?* | |
// @include https://twitter.com/oauth/authenticate?* | |
// @include http://api.twitter.com/oauth/authorize?* | |
// @include http://api.twitter.com/oauth/authenticate?* | |
// @include https://api.twitter.com/oauth/authorize?* | |
// @include https://api.twitter.com/oauth/authenticate?* | |
// ==/UserScript== | |
(function () { | |
const msgElem = document.querySelector(".signin-content > h4"); | |
const msgText = msgElem.textContent; | |
const writeRequired = ["update", "\u66F4\u65B0"].some(function (w) { return msgText.indexOf(w) !== -1; }); | |
const readOnly = ["to access your", "\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u3088\u3046\u3068"] | |
.some(function (w) { return msgText.indexOf(w) !== -1; }); | |
if (!writeRequired && !readOnly) | |
return; | |
function p(text, style) { | |
const p = document.createElement("p"); | |
p.textContent = text; | |
p.setAttribute("style", style); | |
return p; | |
} | |
const acsType = (writeRequired ? "Write" : "Read Only"); | |
const bgColor = (writeRequired ? "#ae0008" : "#fbd71c"); | |
const fgColor = (writeRequired ? "#ffffff" : "#000000"); | |
const caution = document.createElement("div"); | |
caution.setAttribute("style", ["-moz-border-radius : 3px;", | |
"-webkit-border-radius : 3px;", | |
"border-radius : 3px;", | |
"padding : 10px;", | |
"margin : 10px;", | |
"background-color : " + bgColor + ";", | |
"-moz-box-shadow : 0px 0px 3px #353535;", | |
"-webkit-box-shadow : 0px 0px 3px #353535;", | |
"box-shadow : 0px 0px 3px #353535;", | |
"text-align : center"].join("\n")); | |
caution.appendChild(p("CAUTION", "color : " + fgColor + "; font-weight : bold; font-size : 40px;")); | |
caution.appendChild(p("This application is requesting a '" + acsType + "' access", | |
"color : " + fgColor + "; font-size : 17px;")); | |
msgElem.parentNode.insertBefore(caution, msgElem.nextSibling); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment