Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/Develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardufoin committed Sep 30, 2018
2 parents ec40736 + 7576312 commit 994ac10
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 44 deletions.
8 changes: 5 additions & 3 deletions Scripts/Class/Bookmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ var Bookmarks = {
type: "GET",
url: "http://kissmanga.com/BookmarkList",
success: (html) => {
html = html.replace(/<img[^>]*>/g, "");
obj.setBookmarks($(html).find(".listing tr:not(:first-child)"));
// We remove elements making FireFox cry about CSP (onClick, Images and everything beside the .listing table)
html = html.replace(/onClick=['"].+?['"]|<img[^>]*>|\r?\n|\r/gi, "");
let table = html.match(/<table[^>]+class=['"]listing['"].*<\/table>/gi)[0];
obj.setBookmarks($(table).find("tr:not(:first-child)"));
obj.executeCallbacks();
},
error: (req, status, err) => {
console.log("Error " + req.status + " while connecting to bookmarks list: " + err);
console.error("Error " + req.status + " while connecting to bookmarks list: " + err);
if (errorCB) {
errorCB(req.status);
}
Expand Down
23 changes: 15 additions & 8 deletions Scripts/Class/FreeKiss.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var FreeKiss = {
* @param {FreeKiss} fk - The FreeKiss instance calling init
*/
init: function(fk) {
chrome.storage.sync.get("fk-status", (opt) => {
this.saveMethod().get("fk-status", (opt) => {
if (opt['fk-status'] != null && Object.keys(opt['fk-status']).length > 0) {
let st = this.decompress(opt['fk-status']);
if (st != null) this.mangas = st;
Expand Down Expand Up @@ -166,12 +166,16 @@ var FreeKiss = {
save: function() {
let cmprs = this.compress(this.mangas);
if (cmprs != null) {
chrome.storage.sync.set({"fk-status": cmprs});
this.saveMethod().set({"fk-status": cmprs});
}
},
/** Clear the status in localstorage */
clear: function() {
chrome.storage.sync.remove("fk-status");
this.saveMethod().remove("fk-status");
},
/** Determine the save method depending on the browser */
saveMethod: function() {
return (navigator.userAgent.indexOf("Firefox") != -1 ? chrome.storage.local : chrome.storage.sync);
}
},
/**
Expand Down Expand Up @@ -230,13 +234,16 @@ var FreeKiss = {
*/
updateIcon: function(bookmarks, refreshAlarm) {
if (this.Options.get("showUnreadOnIcon") === true) {
chrome.runtime.sendMessage({message: "UpdateIcon", freekiss: this, bookmarks: bookmarks, refreshAlarm: refreshAlarm});
// NOTE: Objects have to be stripped of their methods or Firefox will refuse to send them... (Instead of, you know, sending them without their methods...)
chrome.runtime.sendMessage({message: "UpdateIcon", freekiss: JSON.parse(JSON.stringify(this)), bookmarks: JSON.parse(JSON.stringify(bookmarks)), refreshAlarm: refreshAlarm});
}
}
};

/** Prevent onclick ads on KissManga from firing. */
var script = document.createElement('script');
script.textContent = "var f=EventTarget.prototype.addEventListener;EventTarget.prototype.addEventListener=function(type,fn,capture){this.f=f;if(type!='mousedown'){this.f(type,fn,capture);}}";
(document.head || document.documentElement).appendChild(script);
script.remove();
if (window.location.hostname == "kissmanga.com") {
var script = document.createElement('script');
script.textContent = "var f=EventTarget.prototype.addEventListener;EventTarget.prototype.addEventListener=function(type,fn,capture){this.f=f;if(!/b\\(['\"]\\w+['\"]\\)/g.test(fn.toString())){this.f(type,fn,capture);}};";
(document.head || document.documentElement).appendChild(script);
script.remove();
}
30 changes: 23 additions & 7 deletions Scripts/Class/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var Management = {
* @param {jQuery Node} statusDisplay - Node that will contain the status displayers. If null, they are not added to the page
*/
_Status: function(manager, statusDisplay = null) {
$(manager).append('\
let display_node = '\
<span class="fk-statusManagement fk-hide">\
<div class="fk-statusSubMenu fk-hide">\
<a class="fk-defaultStatus" title="Reading">\
Expand All @@ -94,7 +94,8 @@ var Management = {
<span class="fk-imgHelper"></span><img style="width:16px" src="' + this.Images.Default + '">\
</a>\
</span>\
');
';
$(manager).append(display_node.replace(/\t/g, ""));
// Display the submenu when the status button is clicked
$(manager).find(".fk-statusDisplay").click((e) => {
// Close all currently opened submenu
Expand Down Expand Up @@ -389,7 +390,7 @@ function RemoveManga(node) {
$.ajax(
{
type: "POST",
url: "/Bookmark/" + mid + "/remove",
url: "http://kissmanga.com/Bookmark/" + mid + "/remove",
success: function (message) {
if (message != "") {
Bookmarks.remove(mid);
Expand All @@ -399,6 +400,9 @@ function RemoveManga(node) {
// TODO ERROR ?
HideLoading(manager, true);
}
},
error: function(request, status, error) {
console.error("FreeKiss: " + error + "\n\nIf the error persist, fill a report on the extension's store page.");
}
}
);
Expand All @@ -420,7 +424,7 @@ function AddManga(node) {
$.ajax(
{
type: "GET",
url: $(manager).attr("data-url"),
url: "http://kissmanga.com/" + $(manager).attr("data-url"),
success: function (html) {
let reg = html.match(/mangaID=(\d+)/);
if (reg != null) {
Expand All @@ -430,6 +434,9 @@ function AddManga(node) {
// TODO ERROR ?
HideLoading(manager);
}
},
error: function(request, status, error) {
console.error("FreeKiss: " + error + "\n\nIf the error persist, fill a report on the extension's store page.");
}
}
);
Expand All @@ -447,7 +454,7 @@ function AddMangaQuery(node, manager) {
$.ajax(
{
type: "POST",
url: "/Bookmark/" + node.attr("mid") + "/add",
url: "http://kissmanga.com/Bookmark/" + node.attr("mid") + "/add",
success: function (message) {
if (message != "") {
Bookmarks.sync(function() {
Expand All @@ -459,6 +466,9 @@ function AddMangaQuery(node, manager) {
// TODO ERROR ?
HideLoading(manager);
}
},
error: function(request, status, error) {
console.error("FreeKiss: " + error + "\n\nIf the error persist, fill a report on the extension's store page.");
}
}
);
Expand All @@ -477,7 +487,7 @@ function MarkAsRead(node) {
$.ajax(
{
type: "POST",
url: "/Bookmark/MarkBookmarkDetail",
url: "http://kissmanga.com/Bookmark/MarkBookmarkDetail",
data: {
"bdid": bid,
"strAlreadyRead": 1
Expand All @@ -492,6 +502,9 @@ function MarkAsRead(node) {
// TODO ERROR ?
}
HideLoading(manager, true);
},
error: function(request, status, error) {
console.error("FreeKiss: " + error + "\n\nIf the error persist, fill a report on the extension's store page.");
}
}
);
Expand All @@ -510,7 +523,7 @@ function MarkAsUnread(node) {
$.ajax(
{
type: "POST",
url: "/Bookmark/MarkBookmarkDetail",
url: "http://kissmanga.com/Bookmark/MarkBookmarkDetail",
data: {
"bdid": bid,
"strAlreadyRead": 0
Expand All @@ -525,6 +538,9 @@ function MarkAsUnread(node) {
// TODO ERROR ?
}
HideLoading(manager, true);
},
error: function(request, status, error) {
console.error("FreeKiss: " + error + "\n\nIf the error persist, fill a report on the extension's store page.");
}
}
);
Expand Down
17 changes: 2 additions & 15 deletions Scripts/FreeKiss/Export.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ var Format = {
JSON: 2
};

/**
* Download the text as "filename" on the user's computer
* @param {string} filename - Name of the created file (needs to contain the extension)
* @param {string} text - Content of the created file
*/
function DownloadFile(filename, text) {
let link = '<a href="data:text/plain;charset=utf-8,' + encodeURIComponent(text) + '" download="' + filename + '" style="display:none;"></a>';
$(link)[0].click();
}

/** Show the formats choice buttons */
function ShowFormats() {
$("#formats button").removeClass("fk-hide");
Expand All @@ -37,7 +27,8 @@ function HideFormats() {
function ShowPreview(content, ext) {
$("#preview").removeClass("fk-hide");
$("#previewContent").text(content);
$("#previewExt").text(ext);
$("#previewDownload").attr("href", "data:application/octet-stream;charset=utf-8," + encodeURIComponent(content));
$("#previewDownload").attr("download", "Kissmanga-Bookmarks." + ext);
}

/** Hide the #preview div */
Expand Down Expand Up @@ -83,10 +74,6 @@ function Export() {
$("#jsonFormat").click(() => {
ChooseFormat(Format.JSON);
});

$("#previewDownload").click(() => {
DownloadFile("Kissmanga-Bookmarks." + $("#previewExt").text(), $("#previewContent").text());
});
});
}

Expand Down
3 changes: 2 additions & 1 deletion Styles/FreeKiss/Export.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@
height: 25px;
font-size: 13px;
font-weight: bold;
padding: 0;
padding: 4px 10px 4px 10px;
background-image: linear-gradient(to bottom, #34db58, #29b941);
box-shadow: 0px 1px 3px #666666;
border-radius: 5px;
border: none;
outline: none;
color: white;
text-decoration: none;
}

#previewDownload:hover {
Expand Down
1 change: 1 addition & 0 deletions Styles/FreeKiss/Options.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ html, body {
margin: 0;
padding: 0;
background-color: #E8E8E8;
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
}

#navigation {
Expand Down
76 changes: 72 additions & 4 deletions Styles/Popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
background-color: #353535;
overflow: hidden;
}

#container {
width: 350px;
height: 228px;
}

#title {
Expand Down Expand Up @@ -46,7 +46,6 @@ body {
border-radius: 1px;

margin-left: -3px;
height: 172px;
width: 356px;
padding-top: 3px;
}
Expand Down Expand Up @@ -113,9 +112,12 @@ td a:not(.active):hover {
background-color: #A1A1A1;
}

/* Range generated by http://danielstern.ca/range.css/#/ */
input[type=range] {
-webkit-appearance: none;
margin-bottom: 5px;
width: 129px;
height: 6px;
margin: 0px;
}

input[type=range]:focus {
Expand All @@ -125,18 +127,84 @@ input[type=range]:focus {
input[type=range]::-webkit-slider-runnable-track {
height: 6px;
cursor: pointer;
box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
background: #3071a9;
border-radius: 1.3px;
border: 0.2px solid #010101;
}

input[type=range]::-webkit-slider-thumb {
box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
border: 1px solid #000000;
height: 18px;
width: 18px;
border-radius: 10px;
background: #ffffff;
cursor: pointer;
-webkit-appearance: none;
margin-top: -7px;
margin-top: -6.2px;
}

input[type=range]:focus::-webkit-slider-runnable-track {
background: #367ebd;
}

input[type=range]::-moz-range-track {
height: 6px;
cursor: pointer;
box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
background: #3071a9;
border-radius: 1.3px;
border: 0.2px solid #010101;
}

input[type=range]::-moz-range-thumb {
box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
border: 1px solid #000000;
height: 18px;
width: 18px;
border-radius: 10px;
background: #ffffff;
cursor: pointer;
}

input[type=range]::-ms-track {
height: 6px;
cursor: pointer;
background: transparent;
border-color: transparent;
color: transparent;
}

input[type=range]::-ms-fill-lower {
background: #2a6495;
border: 0.2px solid #010101;
border-radius: 2.6px;
box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
}

input[type=range]::-ms-fill-upper {
background: #3071a9;
border: 0.2px solid #010101;
border-radius: 2.6px;
box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
}

input[type=range]::-ms-thumb {
box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
border: 1px solid #000000;
height: 18px;
width: 18px;
border-radius: 10px;
background: #ffffff;
cursor: pointer;
height: 6px;
}

input[type=range]:focus::-ms-fill-lower {
background: #3071a9;
}

input[type=range]:focus::-ms-fill-upper {
background: #367ebd;
}
1 change: 1 addition & 0 deletions Views/Background.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="../Tools/jquery-3.1.1.min.js"></script>
<script src="../Tools/lz-string.min.js"></script>
<script src="../Scripts/Class/FreeKiss.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions Views/Export.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<title>FreeKiss - Export</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="../Styles/FreeKiss/Options.css">
<link rel="stylesheet" href="../Styles/FreeKiss/Export.css">
</head>
Expand Down Expand Up @@ -30,8 +31,7 @@ <h2 class="exportTitle">Choose export format</h2>
<div id="preview" class="fk-hide">
<h2 class="exportTitle">Preview</h2>
<div id="previewContent"></div>
<span id="previewExt" class="fk-hide">txt</span>
<button id="previewDownload">Download result</button>
<a href="#" id="previewDownload">Download result</a>
</div>
</div>

Expand Down
Loading

0 comments on commit 994ac10

Please sign in to comment.