Permalink
Browse files

download

  • Loading branch information...
1 parent 8892c20 commit 8d074ecbfc36202089eb501ae054f3c3570dbb08 Fan Yu committed Aug 8, 2012
Showing with 240 additions and 64 deletions.
  1. +55 −0 base.js
  2. +0 −58 contentscript.js
  3. +2 −1 default.js
  4. +167 −0 jquery.js
  5. +10 −0 manifest .json.debug
  6. +6 −5 manifest.json
View
55 base.js
@@ -0,0 +1,55 @@
+console.log("base script loaded");
+var imges = [];
+var imgUrls = [];
+$("<div/>").attr({ id: "div_oprationpanel" })
+ .css({
+ border: "solid 1px green",
+ padding: 5
+ }).appendTo($(document.body));
+
+$("<div/>").attr("id", "div_saveimg")
+ .css({
+ border: "solid 1px orange",
+ width: 30,
+ height: 15
+ }).html("save").appendTo($("#div_oprationpanel"));
+$("#div_oprationpanel").float({ position: "rm" });
+$("#div_saveimg").hover(addBackgroundColor, removeBackgroundColor);
+function addBackgroundColor(event) {
+ $(this).css("backgroundColor", "orange");
+}
+function removeBackgroundColor(event) {
+ $(this).css("backgroundColor", "");
+}
+var image_downloader = {
+ download_images: function (images) {
+ var images_container = document.getElementById('image_downloader_images_container');
+ if (!images_container) {
+ images_container = document.createElement('div');
+ images_container.id = 'image_downloader_images_container';
+ images_container.style.display = 'none';
+ }
+ document.body.appendChild(images_container);
+
+ while (images_container.children.length > 0) {
+ images_container.removeChild(images_container.children[images_container.children.length - 1])
+ }
+
+ for (var i in images) {
+ var anchor = document.createElement('a');
+ anchor.href = images[i];
+ anchor.download = '';
+ images_container.appendChild(anchor);
+ anchor.click();
+ }
+
+ document.body.removeChild(images_container);
+ }
+}
+
+$("#div_saveimg").bind("click", function (event) {
+ $(imges).each(function(index){
+ imgUrls.push(this.src);
+ });
+ image_downloader.download_images(JSON.stringify(imgUrls));
+});
View
@@ -1,62 +1,4 @@
console.log("content script loaded");
-
-$("<div/>").attr({ id: "div_oprationpanel" })
- .css({
- border: "solid 1px green",
- padding: 5
- }).appendTo($(document.body));
-
-$("<div/>").attr("id", "div_saveimg")
- .css({
- border: "solid 1px orange",
- width: 30,
- height: 15
- }).html("save").appendTo($("#div_oprationpanel"));
-
-$("#div_oprationpanel").float({ position: "rm" });
-$("#div_saveimg").hover(addBackgroundColor, removeBackgroundColor);
-function addBackgroundColor(event) {
- $(this).css("backgroundColor", "orange");
-}
-function removeBackgroundColor(event) {
- $(this).css("backgroundColor", "");
-}
-
-var image_downloader = {
- download_images: function (images) {
- var images_container = document.getElementById('image_downloader_images_container');
- if (!images_container) {
- images_container = document.createElement('div');
- images_container.id = 'image_downloader_images_container';
- images_container.style.display = 'none';
- }
- document.body.appendChild(images_container);
-
- while (images_container.children.length > 0) {
- images_container.removeChild(images_container.children[images_container.children.length - 1])
- }
-
- for (var i in images) {
- var anchor = document.createElement('a');
- anchor.href = images[i];
- anchor.download = '';
- images_container.appendChild(anchor);
- anchor.click();
- }
-
- document.body.removeChild(images_container);
- }
-}
-
-$("#div_saveimg").bind("click", function (event) {
- for (var img in imges) {
- imgUrls.push(img.src);
- }
- image_downloader.download_images(JSON.stringify(imgUrls));
-});
-
-var imges = [];
-var imgUrls = [];
imges.contains = function (arr) {
for (var i = 0; i < this.length; i++) {
if (this[i] == arr)
View
@@ -1,5 +1,6 @@
chrome.browserAction.onClicked.addListener(function (tab) {
- chrome.tabs.executeScript(null, { file: 'jquery-1.4.1.min.js', allFrames: true });
+ chrome.tabs.executeScript(null, { file: 'jquery.js', allFrames: true });
chrome.tabs.executeScript(null, { file: 'float.js' });
+ chrome.tabs.executeScript(null, { file: 'base.js' });
chrome.tabs.executeScript(null, { file: 'contentscript.js', allFrames: true });
});
Oops, something went wrong.

0 comments on commit 8d074ec

Please sign in to comment.