Created
February 19, 2014 02:43
-
-
Save yajd/9085126 to your computer and use it in GitHub Desktop.
ff-addon-script: Use atob and btoa in privelaged scope (no access to window)
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
const {utils: Cu} = Components; | |
const { atob, btoa } = Cu.import("resource://gre/modules/Services.jsm"); | |
//can now use atob and btoa freely | |
//if it is utf-8 then do the following: | |
function atobUTF8(data) { | |
return decodeURIComponent(escape(atob(data))) | |
} | |
function btoaUTF8(data) { | |
return btoa(unescape(encodeURIComponent(data))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment