I am trying to create a Pin It button (Pinterest extension), for example, a chrome extension. What I tried is running the script when I click on an extension that can iterate through all available images on a web page, save it in LocalStorage . Now I need to call an iframe (another domain) and access these images . Since you can only access localstorage from the same domain, I'm pretty confused since Pinterest manages to store all the images from a web page (temporarily, and not on its server) and then use it in an iframe.
I also saw the PinIt Button extension code, but I can not understand any of it, because it is too confused / encrypted or something else.
I read about chrome.storageapi and I could not understand it well enough. I'm not even sure that this is what I need to do in this case. (This is the first time I am developing a chrome extension). Can someone shed some light on this and give me the best way to achieve this functionality?
PS I completed this extension without using it <iframe>, but I need to do it with <iframe>.
EDIT 1: I cannot write the full code here, but here is the thread / structure / my attempts
I start withbackground.js
chrome.browserAction.onClicked.addListener(function (tab) {
chrome.tabs.executeScript(tab.id, {
"file": "bookmarklet.js"
})
});
In bookmarklet.js:
jQuery('body').append('<iframe class="vw_parent" id="image-grabber-container" src="" style="height: 100% !important; width: 100% !important; position: fixed !important; margin: 0% auto !important; background: rgba(17, 17, 17, 0.9) !important; left: 0 !important; right: 0 !important; z-index: 999999999 !important; top: 0% !important;"></iframe>');
jQuery('img').each(function() {
var allImgs = jQuery(this);
localStorage.setItem('myLocalImgs', allImgs);
})
vwgrid = "https://mydomain/FileToBeInjectedInIframe.php";
jQuery('#image-grabber-container').attr('src', vwgrid);
Now in FileToBeInjectedInIframe.php
var abcde = localStorage.getItem('myLocalImgs');
console.log(abcde);
2: DelightedD0D, /
1. -
2. , -, iFrame
3. iFrame,
4. iFrame: POST IMAGE, iFrame, , iFrame
5. iFrame, , -, /cookie .
( , ), pinterest iFrame