chrome.tabs.query({active: true, lastFocusedWindow: true}, function(arrayOfTabs) { var tab = arrayOfTabs[0]; var url = tab.url; console.log("URL = " + url); chrome.storage.sync.set({"currentTabURL": url}, function(){ console.log("currentTabURL: " + url); });});
function accessCurrentTabURL(){ chrome.storage.sync.get(["currentTabURL"], function(result){ console.log("URL of current Tab: " + result.currentTabURL); };}
accessCurrentTabURL();
Enter code here...
{ "manifest_version": 2, "name": "MR QC Auditor View", "version": "1.0", "description": "This Google Chrome extension shows Ad ID's for print ads, and then links to Ad Tagger for tagging corrections", "icons": { "128": "MRLogo128.png", "48": "MRLogo48.png", "16": "MRLogo16.png" }, "background": { "scripts": ["background.js"], "persistent": false }, "browser_action":{ "default_icon": "MRLogo16.png", "default_popup": "popup.html" }, "permissions": [ "storage", "tabs", "activeTab" ]}
<!DOCTYPE html><html> <head> <title>MR QC Auditor View</title> <script src="popup.js"> </script> </head> <body> <img src="MRLogo128.png"/> <h1>Current Ad's Brand: <h1><span id="brandNameText"></span> <h2>Link To Ad Tagger</h2><span><a href="http://www.google.com">Link</a></span> </body></html>
// Current Post To Look At:
// Related Google + Group Post:
chrome.extension.onRequest.addListener(function(request, sender, sendResponse){ if (request.message) { var i = 0; var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); for (; i < printAds.length; i++){ console.log("Current Ad ID = "); } }})
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/8e4dab5c-6a6f-498d-9f25-0f7d1bf82ff7%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
☆PhistucK
To post to this group, send email to chromium-...@chromium.org.
☆PhistucK
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/8e4dab5c-6a6f-498d-9f25-0f7d1bf82ff7%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/0f7cc913-8817-4ec7-8ca9-43b999e93f30%40chromium.org.
Here's an updated version of all my current scripts.
I'm still pretty stuck because this is getting a bit above my head, even with the okay tutorials I found on YouTube. I have to complain because Google's actual tutorial doesn't ever get this deep into how to actually really make use of all of these methods.
It's either this or I'm too beginner, so bear with me, since I have no idea what I'm doing, but I really really really want to make this extension to make my life easier at work since I can only use Google Chrome.
I have tried the following:
chrome.runtime.onMessage.addListener(function(){ if (request.message) {
var printAds = document.getElementsByClassName("ad-image printadviewable pointer");
for (var i = 0; i < printAds.length; i++){ console.log("Current Ad Id = " + printAds[i]); } }})
// Use chrome.runtime.onMessage()// Documentation:
// Use chrome.runtime.executeScript// Documentation:// chrome.runtime.executeScript// ^ Couldn't find documentation:// Found this instead:// chrome.runtime.executeScriptchrome.runtime.sendMessage({}, function(){ // Send DOM content: })
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/976349c0-77f5-472a-a894-fdf66b7930f9%40chromium.org.
Enter code here...chrome.runtime.onMessage.addListener(function(){
// Parameters for chrome.tabs.executeScript()// chrome.tabs.executeScript(integer tabId, object details, function callback)// I want to pass in the first tab, and if I'm not mistaken, this is found in tab "0"// I'm not sure
chrome.tabs.executeScript(0, {}, function(){
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b0a5ba95-4e9a-45ff-a054-a739fcc81c5f%40chromium.org.
☆PhistucK
To post to this group, send email to chromium-...@chromium.org.
☆PhistucK
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b0a5ba95-4e9a-45ff-a054-a739fcc81c5f%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b23f4552-206c-4fbb-a184-3c800867adaa%40chromium.org.
What does not work?☆PhistucK
☆PhistucK
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b0a5ba95-4e9a-45ff-a054-a739fcc81c5f%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
What does not work?☆PhistucK
☆PhistucK
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b0a5ba95-4e9a-45ff-a054-a739fcc81c5f%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b23f4552-206c-4fbb-a184-3c800867adaa%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/99b9af50-8b1e-4d64-8fde-eff31427d812%40chromium.org.
// Current Post To Look At:
// Related Google + Group Post:
// Use chrome.runtime.onMessage()// Documentation:
// chrome.tabs.executeScript():chrome.tabs.executeScript({"code": 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); for (var i = 0; i < printAds.length; i++){console.log("Current Ad Id = " + printAds[i]);}'}, function(){ if (request.message) { // Use chrome.runtime.sendMessage() to send DOM content: chrome.runtime.sendMessage({greeting: "hello"}, function(response){ console.log("DOM Content Sent To Chrome Extension Webpage"); }) }})
<!DOCTYPE html><html> <head> <title>MR QC Auditor View</title> <script src="popup.js"> </script> </head> <body> <img src="MRLogo128.png"/> <h1>Current Ad's Brand: <h1><span id="brandNameText"></span> <h2>Link To Ad Tagger</h2><span><a href="http://www.google.com">Link</a></span> </body></html>
// Receive the response from background.js by adding a related listener:
// Communication with the embedding page example:
window.addEventListener("message":, function(event){ if (event.source != window){ return; } if (event.data.type && (event.data.type == "FROM_PAGE")){ console.log("Content script received: " + event.data.text); port.postMessage(event.data.text); }}, false);
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/041086cb-1edf-47fd-a2f0-f89a065aa514%40chromium.org.
chrome.runtime.onMessage.addListener("DOM Content Received", function sendResponse(){ console.log("DOM Content Received");});
// Current Post To Look At:
// Related Google + Group Post:
// Use chrome.runtime.onMessage()// Documentation:
// chrome.tabs.executeScript():chrome.tabs.executeScript({"code": 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); for (var i = 0; i < printAds.length; i++){console.log("Current Ad Id = " + printAds[i]);}'}, function(){ if (request.message) { // Use chrome.runtime.sendMessage() to send DOM content: chrome.runtime.sendMessage({greeting: "hello"}, function(response){ console.log("DOM Content Sent To Chrome Extension Webpage"); }) }})
{ "manifest_version": 2, "name": "MR QC Auditor View", "version": "1.0", "description": "This Google Chrome extension shows Ad ID's for print ads, and then links to Ad Tagger for tagging corrections", "icons": { "128": "MRLogo128.png", "48": "MRLogo48.png", "16": "MRLogo16.png" }, "background": { "scripts": ["background.js"], "persistent": false }, "browser_action":{ "default_icon": "MRLogo16.png", "default_popup": "popup.html" }, "permissions": [ "storage", "tabs", "activeTab" ]}
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/1ead56b4-08c1-4850-bceb-1f9ae18599f8%40chromium.org.
chrome.runtime.onMessage.addListener(function sendResponse(){
console.log("DOM Content Received");});
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/5a9306aa-c4f4-46e9-bbb7-df296d146f70%40chromium.org.
// Current Post To Look At:
// Related Google + Group Post:
// Use chrome.runtime.onMessage()// Documentation:
// chrome.tabs.executeScript():chrome.tabs.executeScript({"code": 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); for (var i = 0; i < printAds.length; i++){console.log("Current Ad Id = " + printAds[i]);}'}, function(){
// Use chrome.runtime.sendMessage() to send DOM content:
chrome.runtime.sendMessage({greeting: "hello"}, function(){ // Call chrome.runtime.sendResponse() // console.log("DOM Content Sent To Chrome Extension Webpage"); })})
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/e6289737-b85f-465a-93c1-5420e6e9f01a%40chromium.org.
// Current Post To Look At:
// Related Google + Group Post:
// Use chrome.runtime.onMessage()// Documentation:
// chrome.tabs.executeScript():chrome.tabs.executeScript({"code": 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); for (var i = 0; i < printAds.length; i++){console.log("Current Ad Id = " + printAds[i]);}'}, function(){ // Use chrome.runtime.sendMessage() to send DOM content: chrome.runtime.sendMessage({greeting: "hello"}, function(){ // Call chrome.runtime.sendResponse() // console.log("DOM Content Sent To Chrome Extension Webpage"); })})
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/e6289737-b85f-465a-93c1-5420e6e9f01a%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/6de319ee-714e-4a87-8213-dd3ed6aff688%40chromium.org.
var printAds = document.getElementsByClassName("ad-image printadviewable pointer");
for (var i = 0; i<printAds.length; i++){console.log("Current Ad Id = " + $(printAds[i]).attr("data-adid"));}
// Current Post To Look At:
// Related Google + Group Post:
// Use chrome.runtime.onMessage()// Documentation:
// chrome.tabs.executeScript():
chrome.tabs.executeScript({"code": ''var printAds = document.getElementsByClassName(code: 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); ', allFrames: true}, function(stuff){// chrome.tabs.executeScript({"code": "console.log('This is A Test')"}, function(stuff){
// Use chrome.runtime.sendMessage() to send DOM content: chrome.runtime.sendMessage({greeting: "hello"}, function(){ // Call chrome.runtime.sendResponse() // console.log("DOM Content Sent To Chrome Extension Webpage"); })})
/*
Console Based Code That Works:
$("#ad-image printadviewable pointer").find("img").attr("data-adid");
var printAds = document.getElementsByClassName("ad-image printadviewable pointer");
for (var i = 0; i<printAds.length; i++){console.log("Current Ad Id = " + $(printAds[i]).attr("data-adid"));}*/
// One Line Version For Code Dictionary Key// 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); for (var i = 0; i<printAds.length; i++){console.log("Current Ad Id = " + $(printAds[i]).attr("data-adid"));}'
<!DOCTYPE html><html> <head> <title>MR QC Auditor View</title>
<script src="jquery-3.3.1.min.js"> </script>
<script src="popup.js"> </script> </head> <body> <img src="MRLogo128.png"/> <h1>Current Ad's Brand: <h1><span id="brandNameText"></span> <h2>Link To Ad Tagger</h2><span><a href="http://www.google.com">Link</a></span> </body></html>
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/97e85b2a-0c40-4722-ba4b-6c04355885d3%40chromium.org.
// Current Post To Look At:
// Related Google + Group Post:
// Use chrome.runtime.onMessage()// Documentation:
// chrome.tabs.executeScript():
/*Old Code Block;
chrome.tabs.executeScript({file: 'jquery-3.3.1.min.js'}, function () { chrome.tabs.executeScript({code: 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); ', allFrames: true}, function(stuff){
chrome.runtime.sendMessage({greeting: "hello"}, function(){ // Call chrome.runtime.sendResponse() // console.log("DOM Content Sent To Chrome Extension Webpage"); })
}}); });*/
chrome.tabs.executeScript({file: 'jquery-3.3.1.min.js'}, function () { chrome.tabs.executeScript({code: 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); for (var i = 0; i<printAds.length; i++){console.log("Current Ad Id = " + $(printAds[i]).attr("data-adid"));}', allFrames: true}); });
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/1530fe59-2f5f-4c55-90d2-ed5c67d8a936%40chromium.org.
// Current Post To Look At:
// Related Google + Group Post:
// Use chrome.runtime.onMessage()// Documentation:
// chrome.tabs.executeScript():
/*Old Code Block;
chrome.tabs.executeScript({file: 'jquery-3.3.1.min.js'}, function () { chrome.tabs.executeScript({code: 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); ', allFrames: true}, function(stuff){ chrome.runtime.sendMessage({greeting: "hello"}, function(){ // Call chrome.runtime.sendResponse() // console.log("DOM Content Sent To Chrome Extension Webpage"); })}}); });*/
// Added an array called "adArray" that utilizes the .push() JavaScript array function
// I need to somehow add this to the popup.html page itself, look for the StackOverflow related pages.
chrome.tabs.executeScript({file: 'jquery-3.3.1.min.js'}, function (adArray) { chrome.tabs.executeScript({code: 'var printAds = document.getElementsByClassName("ad-image printadviewable pointer"); var adArray = []; for (var i = 0; i<printAds.length; i++){console.log("Current Ad Id = " + $(printAds[i]).attr("data-adid")); adArray.push($(printAds[i]).attr("data-adid"))}', allFrames: true}); });
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/e41b637e-661b-43fa-b8db-0cf31a259c36%40chromium.org.