content-script

Chrome extensions: variable undefined in chrome extension even though it exists in console

落花浮王杯 提交于 2019-12-13 05:19:21
问题 In my content scripts for my chrome extension, I dynamically load a external js file onto a html page once it is finished loading. This js file I load will define a variable called rfk . I have a set Interval for when rfk is defined, it will execute a script. However, even after succesfully loading the page, my content script will never find rfk to be defined, even though I can check through the browser console and find that rfk exists. "content_scripts": [ { "matches": ["*://www.att.com/*"],

Chrome Extension to Redirect to URL with Parameter

我的梦境 提交于 2019-12-13 02:09:50
问题 I'm attempting to create a Chrome extension which will add a parameter to the end of a URL if the URL matches a given pattern ( *://*.mydomain.com/s/* ). Below is the manifest file and background script I have, but I cannot get it working. What am I doing wrong? manifest.json: { "manifest_version": 2, "name": "Search Grid View", "version": "0.1", "description": "Changes MyDomain.com search to grid view by default", "background": { "scripts": ["background.js"] }, "permissions": [ "tabs",

IFrame in content script. How to communicate with main.js?

纵然是瞬间 提交于 2019-12-12 16:01:59
问题 My Firefox add-on opens Fancybox (type: "iframe") from a content script (page-mod). In the Fancybox I show my own HTML page ( my_fancybox_stuff.html ) that is located in my own server. Now, from the my_fancybox_stuff.js (javascript of my_fancybox_stuff.html ), can I send a message to the add-on's main.js ? Or to the content script that opened the Fancybox? I was hoping the global 'self' object to be accessible from my_fancybox_stuff.js as it is accessible from the content script that opened

what are content scripts in chrome inspector

送分小仙女□ 提交于 2019-12-12 07:46:04
问题 While this could be a very basic thing, I can't seem to find an answer to this one. I see a lot of discussion about content scripts . When I open web inspector in chrome , and select sources , I see a tab called content scripts . I see a couple of random numbers and a number of scripts and I can't seem to figure out what these are. How are these being shown? where are these coming from? I can't see my server serving any of these. 回答1: In Google Chrome, content scripts are JavaScript files

Including gmail.js

两盒软妹~` 提交于 2019-12-12 05:26:42
问题 I'm trying to include gmail.js from here. But the object gmsrc is invalid, the function get.user_email() fails. I'm trying to develop a Chrome extention, the chrome developer tools (F12) tells me Uncaught TypeError: Cannot read property 'user_email' of undefined Here is my code: var jq = document.createElement('script'); jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"; document.getElementsByTagName('body')[0].appendChild(jq); var gmsrc = document.createElement(

how to pass localstorage from popup.js to content.js

我的未来我决定 提交于 2019-12-12 04:36:39
问题 i want to pass data from localstorage of popup.hmtl to content script content.js i use popup.html to receive username and password and store it in local storage.Now i want to transfer the data to content script before it execute. **popup.html** <!DOCTYPE html> <html> <head> <script type="text/javascript" async src="popup.js"></script> </head> <body> <table> <tr> <td> Username: <td><input id="u1" type="text" name="uname"> </tr> <tr> <td> Password: <td><input id="u2" type="password" name="pass"

chrome object or chrome.tabs object not accessible from script other than a background script [duplicate]

纵然是瞬间 提交于 2019-12-12 03:18:21
问题 This question already has an answer here : Can `chrome.*` extension API's be used inside content scripts? (1 answer) Closed 4 years ago . I am experimenting with the chrome extensions API and I ran into a problem which I don't understand, I have a background script "background.js" and a content script "content_script.js". background.js chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.executeScript({code:"console.log('background script')"}); chrome.tabs.executeScript(

Auto-load bookmarklet when in webpage as a Google Chrome extension

限于喜欢 提交于 2019-12-12 02:51:38
问题 Basically I made a bookmarklet, and I'd like it to run when a certain wildcarded URL is opened. For some reasons it won't simply run as javascript in a chrome extension, and I'm tired of trying. What I think could work is to make an extension that has a content_script for the specified page(s) (which allows a wildcard via match ), and somehow make it do the same thing that would be done if the user clicked the bookmarklet in the bookmarks bar . However, I do not know how to make this. One

Using AJAX only for whole website,optimal or not

穿精又带淫゛_ 提交于 2019-12-12 01:19:20
问题 I am having a template structure in which there is a single HTML file inside which related HTML & JS files are loaded (using AJAX). Section are loaded as per User's activity(Page never reloads which kind of is good for user experience). i.e. User clicks a menu say "Profile",which causes: jQuery.load method is used to load a file "/some/path/profile.html". jQuery.getScript is used in .load() callback to include js files like "some/path/profile.js",The profile js has event handlers for the

Chrome extension - inject template through content_scripts

若如初见. 提交于 2019-12-11 09:55:39
问题 I'm trying to inject a handlebars template in a page using content_scripts from the Chrome extension, using the following code in the page called from content_scripts : var xhr = new XMLHttpRequest(); xhr.open('GET', chrome.extension.getURL('app/templates/tpl.handlebars'), true); xhr.onreadystatechange = function() { if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { var tplScript = document.createElement('script'); tplScript.text = xhr.responseText; tplScript.id = "mytpl";