Przeglądaj źródła

Initial commit

master
Ben Kurtovic 10 lat temu
commit
da8ebc20ae
4 zmienionych plików z 85 dodań i 0 usunięć
  1. +0
    -0
     
  2. +65
    -0
      centigrade.js
  3. +2
    -0
      jquery.min.js
  4. +18
    -0
      manifest.json

+ 0
- 0
Wyświetl plik


+ 65
- 0
centigrade.js Wyświetl plik

@@ -0,0 +1,65 @@
function patched_anime_checkScoreEnter(e, id) {
if ((window.event ? window.event.keyCode : e.which) == 13)
patched_anime_updateScore(id);
else
return true;
}

function patched_anime_updateScore(entry_id) {
var new_score_centigrade = document.getElementById("scoretext" + entry_id).value;
var new_score = Math.round(new_score_centigrade / 10.);
var payload = {};

$.post("/includes/ajax.inc.php?t=63", {id: entry_id, score: new_score}, function(data) {
document.getElementById("scoreval" + entry_id).innerHTML = new_score_centigrade;
document.getElementById("scoretext" + entry_id).value = "";
document.getElementById("scorediv" + entry_id).style.display = "none";
});

payload[entry_id] = new_score_centigrade;
chrome.storage.local.set(payload);
}

function list_hook() {
// chrome.storage.local.get(null, function(items) { console.log(items); });
// chrome.storage.local.clear();

$("span[id^='scoreval']").each(function(i, el) {
var aid = el.id.split("scoreval")[1];
var oldscorediv = $("#scorediv" + aid);
oldscorediv.attr("id", "delete-me");
var newscorediv = $('<div id="scorediv' + aid + '" style="display: none;"><input type="text" id="scoretext' + aid + '" size="2"><input type="button" value="Go"></div>');
newscorediv.insertAfter(oldscorediv);
oldscorediv.remove();

var input = $("#scoretext" + aid);
var button = input.next();
input.keydown(function(tid) {
return function(e) {
return patched_anime_checkScoreEnter(e, tid);
}
}(aid));
button.click(function(tid) {
return function() {
return patched_anime_updateScore(tid);
}
}(aid));

chrome.storage.local.get(aid, function(items) {
if (aid in items) {
$(el).text(items[aid]);
}
else {
var cur = parseInt($(el).text());
if (!isNaN(cur))
$(el).text(cur * 10);
}
});
});
}

$(document).ready(function() {
if (window.location.href.indexOf("/animelist/") != -1) {
list_hook();
}
});

+ 2
- 0
jquery.min.js
Plik diff jest za duży
Wyświetl plik


+ 18
- 0
manifest.json Wyświetl plik

@@ -0,0 +1,18 @@
{
"manifest_version": 2,
"name": "MyAnimeList Centigrade Scale",
"version": "0.1",

"description": "Adds a centigrade scale to MyAnimeList.net's rating system.",
"short_name": "MAL Centigrade",
"icons": {},

"content_scripts": [{
"matches": ["http://myanimelist.net/*"],
"css": ["centigrade.css"],
"js": ["jquery.min.js", "centigrade.js"]
}],
"permissions": [
"storage"
]
}

Ładowanie…
Anuluj
Zapisz