-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentscript.js
94 lines (82 loc) · 9.08 KB
/
contentscript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*global window, jQuery, document */
(function (jQuery, window, document) {
"use strict";
var $ = jQuery,
docId = "",
bookmarked = -1,
buttonCSS = {
"position": "relative",
"top": 0,
"left": 0,
"margin": 0,
"padding": 0,
"margin-bottom": "-15px",
"text-align": "center",
"cursor": "pointer"
},
url,
userTag,
saveBookmark,
bookmarkImage,
bookmarkedImage;
saveBookmark = function () {
localStorage[docId] = bookmarked;
$("body").append('<img style="display: none" id="bookmarksync" src="http://wespickett.com/testx?bookmarkPDF=' + docId + '&bookmarkPage=' + bookmarked + '" />');
$("#bookmarksync").remove();
};
bookmarkedImage = $('<img id="bookmarked" alt="Bookmarked!" width="120" height="15" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAPCAIAAACgIZz8AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHFBIaEoVAphkAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAAZiS0dEAJ8ApACfFNRw1wAAB6tJREFUWMOFVvtPk1cY7j/U/gBJ+4MkNtkSzeJciYFQAgKtXDbc0LTQdu0HFNZPqRbvraSMfibKNtkFdYq3bYoadTc3BW8gitdd/4c957znnO98bcmSNyfv95znfd7nfXt1WcdLFCXHaZV4rhICNbKlqvit5ay1SoJpl2tdLClrUS4RS+nIR9Wr7KpKR8VxNhJWNQ96a9Ip81PSTtuYcxX2aCWnjuVYiC3r0hdX0hah8zRceFUza4tQY1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rNcSwSTpvatE5P6xCM5tFuQVTWsV95qj0zN5a51u2s8nlqPp8btqaHT7alFeNwccbMrHrVE84hbHh51qxNq7AT6uqBbluMkBdG91i350kmtQ8cjdDzyFGTmn9cKt0qNm3ErVxKxe3ER4Yf6StxdI0ej5TDbYmSho3WxyXIPRBay0sB/kr0yIu+RpLAAAAAASUVORK5CYII=" />');
bookmarkImage = $('<img id="bookmark" alt="Bookmark" width="120" height="15" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAPCAYAAAAvQwurAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHFBIWC02eQdUAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAAZiS0dEAHYApAB26MaPpQAACf5JREFUWMPFWWtQlOcV3hkT84Mx3lL90RmdTpv2ly2buLudWRhcXegM6CYKZBRlCezKguzKsisIYgRHMAGtitwUlgioibYmVk3rZdppbG3aJmNNpqaaoDYo2ubSv/7c03POe/neb8GfaZk58573XJ5zznP4vl3F4ZA/T/3gqVWO5xzRJb4lj5etWwbZr2RLcYITxboLcc4gls9pO02cTJ+wTc/NNk7nE+xmvjMDS8Q7M/KU35lRd3pe9hPq2ed3znC3amRPs2Xi2GfPntabcxrXM+/DCbSzpb6lj2mHvEv1M+v7s+bM/uHs8wuWL4SagRpIjCWgYTQB8dEGSKA0oCTl2cA28sc5JmGzCT1u6OwfE/EqJm7LE/6EUSsT264nNU6ScwRuXPdg1khaNfCelKeycTzXjhu5cR1j9ddgy0kYMYlpZ4N9NpueZG4TY6oPY+7xhOQJZxmLS71B1rLXb5hh1jjPkITkeBJqcYcLcZe403MocxyOJY7x5ZtcUD8aT8dGounoSBSiKZQ3Y3zWjeDJEpVnTNqiEJO2upT0vRk17Eq38mOpmLxHDUwRHzPuylYn42IjGbgpEVtnxJv+2Ay1rTrUh/SlhMR0DTFz9Am4gg9rboUfkz4LI8az2uess2H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EI/7s2/0r0K2zCzJN905NOMS3Hd2gfxREO3Wmh1Kdvp3kXfXb+ooNr3Jy8CakrKeGjvP0KxyewkAsTm2QT1p2guuM7uBefwaPPxqNxytw8xCPMGffQasVl7spn2lpXpFe85gParWPW92YdX7J6CeTsyE17W7zp3GYv5LSg4OltzuEzpyUHvC25KDnCJyWX/TkijmO8HGOJl/PIxzg61it9XokpcVrsNRmTc7xa57jtVj2658q7lmYLX8dl9O5VeNu9Rq6a22vEWv0pv9mr5qRZ8rPdbs9tsfcq5jDmVjw0Z9RqVnMYtW09mjPnSoxcik3ntuaml65eCrRbxzM/embO7Odnn8v6cRa8uPUFcG9zg4uk0Q3uJAqeHra58PTw3Y06nRRHPjfaxemSsVJvdAkMbfNI3WXoFr7QXbKWFW+Ji0+P6k3nqtoenSNiqF/C84ArafXsSrp1vwqTMdjv4VyXtJt1XUYvHp3r4dMlueJ6ScmfjHU1GnM3mvkC86dGLY+e3R5n8eXJsKOOc7oaiW8PvIA7zPpJFv9f9NPPPz1H/9EBl7zK8V1HdJ573uNFvu/A4lWLv11Zufjbr/H/lv/hjIt8i2Cue+5j2qH516T/AvUhmlSbz2ZbAAAAAElFTkSuQmCC" />');
url = window.location.pathname;
docId = url.match(/\/d\/([0-9A-Za-z]+)\//)[1];
userTag = document.getElementById("gbmpn").nextSibling.innerHTML;
docId = userTag + docId;
$(document).ready(function () {
var gCtx = $('#gview-embed-content').contents(),
syncImg;
syncImg = new Image();
syncImg.src = 'http://wespickett.com/testx?bookmarkPDF=' + docId;
syncImg.setAttribute("id","bookmarksyncIn");
syncImg.onload = function () {
var bookmarked = this.width,
bookmarkedPage,
page;
if (localStorage[docId] > bookmarked) {
bookmarked = localStorage[docId];
saveBookmark();
}
if (bookmarked >= 0) {
page = $('.thumb-elements', gCtx).children().eq(bookmarked-1);
bookmarkedImage.prependTo($(page).children().first());
page.addClass("is-bookmarked");
$("#bookmarked").css(buttonCSS);
bookmarkedPage = $("#page-pane", gCtx).children().eq(bookmarked-1);
$("#content-pane", gCtx).scrollTop(bookmarkedPage[0].offsetTop);
}
};
$(".thumb-element", gCtx).mouseenter(function () {
if (!$(this).hasClass("is-bookmarked")) {
$(this).children("#bookmark").remove();
bookmarkImage.prependTo($(this));
$("#bookmark").css(buttonCSS);
}
}).mouseleave(function () {
$(this).find("#bookmark").remove();
}).click(function (e) {
if (e.srcElement.id === "bookmark") {
$(".is-bookmarked", gCtx).removeClass("is-bookmarked");
$("#bookmarked", gCtx).remove();
bookmarkedImage.prependTo($(this));
$(this).addClass("is-bookmarked");
bookmarked = $(this).children(".page-number").text();
saveBookmark();
$(this).find("#bookmark").remove();
$("#bookmarked").css(buttonCSS);
} else if (e.srcElement.id === "bookmarked") {
$(".is-bookmarked", gCtx).removeClass("is-bookmarked");
$("#bookmarked", gCtx).remove();
bookmarked = 0;
saveBookmark();
}
});
});
}(jQuery, window, document));