Created
December 24, 2019 21:35
-
-
Save rjames86/893a3bf25c407e6835a57a228ecdecc3 to your computer and use it in GitHub Desktop.
Revisions
-
rjames86 renamed this gist
Dec 24, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rjames86 created this gist
Dec 24, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ function getMeta(metaName) { const metas = document.getElementsByTagName('meta'); for (let i = 0; i < metas.length; i++) { if (metas[i].getAttribute('property') === metaName) { return metas[i].getAttribute('content'); } } return ''; } const description = getMeta('og:description'); // [97, 122] const lowerCase = []; // [65, 90] const upperCase = []; for (let i = 97; i <= 122; i++) { lowerCase.push(i); } for (let i = 65; i <= 90; i++) { upperCase.push(i); } const getRot13Val = asciiVal => { let newVal; if (upperCase.includes(asciiVal)) { const newIndex = (upperCase.indexOf(asciiVal) + 13) % upperCase.length; newVal = upperCase[newIndex]; } else if (lowerCase.includes(asciiVal)) { const newIndex = (lowerCase.indexOf(asciiVal) + 13) % lowerCase.length; newVal = lowerCase[newIndex]; } else { newVal = asciiVal; } return String.fromCharCode(newVal); } const convertToRot13 = inputString => { let outputString = ''; for (const s of inputString) { const asciiVal = s.charCodeAt(0); outputString += getRot13Val(asciiVal); } return outputString; } const converted = convertToRot13(description) // Call completion to finish completion(converted);