Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade XO and add Prettier #121

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trailingComma: es5
singleQuote: false
30 changes: 14 additions & 16 deletions aeks/aeks.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,40 @@
// @grant none
// ==/UserScript==

(function () {
(function() {
"use strict";

var userscript = function ($) {
const userscript = function($) {
function log(message) {
if (console && console.log) {
console.log(message);
}
}

var userLink = $(".my-profile, .profile-me").attr("href");
const userLink = $(".my-profile, .profile-me").attr("href");

// AEKS has already ran on this site, or the user doesn't have an account here.
if (!userLink || localStorage.aeksFinished) {
log("AEKS cancelled: User has no account or AEKS already finished on this site.");
log(
"AEKS cancelled: User has no account or AEKS already finished on this site."
);
return;
}

var params = [
const params = [
{name: "fkey", value: localStorage["se:fkey"].split(",")[0]},
{name: "key", value: "85"}, // 85 is the id for the keyboard shortcuts setting.
{name: "key", value: "85"}, // 85 is the id for the keyboard shortcuts setting.
{name: "value", value: "true"}, // Enable that setting
{name: "forUserId", value: userLink.match(/\d+/)[0]}
{name: "forUserId", value: userLink.match(/\d+/)[0]},
];

$.post(
"/users/save-preference",
params,
function () {
localStorage.aeksFinished = true;
log("AEKS finished on this site.");
}
);
$.post("/users/save-preference", params, () => {
localStorage.aeksFinished = true;
log("AEKS finished on this site.");
});
};

var aeksScript = document.createElement("script");
const aeksScript = document.createElement("script");
aeksScript.type = "application/javascript";
aeksScript.text = "(" + userscript + ")(jQuery);";
document.body.appendChild(aeksScript);
Expand Down