google-chrome-extension

Showing external content inside browser action popup

六月ゝ 毕业季﹏ 提交于 2019-12-24 23:07:29
问题 I have a Chrome extension that when the user clicks the browser action button the extension opens the popup calls the external API to display an ad Here's what I have: popup.html <div class="v11container" id="v11container">Some Text</div> <script src="http://b.v11media.com/js/client_api/api.js"> </script> //external api <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> //jquery <script type="text/javascript"> v11onload(function() { $.ajax({ url: 'http://localhost:3000/random

how can i know what are the shown parts of the html through javascript

筅森魡賤 提交于 2019-12-24 22:53:10
问题 I want to get all the href elements of the page that are really shown to the user in the current time (only what inside the browser frame, not the parts that above or under). For example, if the user is scrolling down in the page, I want to get in my javascript other elements. Can I even do it? And if not, can I do from Chrome extension? 回答1: Try var res = []; $("a").each(function(i, el) { if (el.getBoundingClientRect().bottom <= window.innerHeight) { res.push($(el).eq(i)); $(el).css({"color"

How to fix “Unchecked runtime.lastError: The message port closed before a response was received.” in self made chrome extension?

旧街凉风 提交于 2019-12-24 21:50:59
问题 I am doing some simple tests to using one time communication between content and background.js. The code is below. I always found the error "Unchecked runtime.lastError: The message port closed before a response was received." occur in my console.log. In the below script, I made 2 step. Step 1. give a message from background to content as soon as the browser action. Step 2. send a message back from content to background. If background received the message, it alerts. I think the error would

Chrome DevTools listen to multiple selections of the same element in the elements panel

佐手、 提交于 2019-12-24 21:46:45
问题 In my Google Chrome DevTools Extension I try to listen to the selections in the DevTools panel "Elements". In particular, it should be possible to listen to the selection of the already selected element. My current implementation method revolves around the function chrome.devtools.panels.elements.onSelectionChanged . The function name already suggests that it is only possible to react to elements that are not currently selected. Therefore I tried to reset or remove the current selection with

Mimetype handling by chrome extension (packaged apps)

穿精又带淫゛_ 提交于 2019-12-24 21:16:22
问题 I'm wondering if a file, with a given mimetype, can be handled by a packaged app. I saw that in manifest file, the nacl_modules could be used to associate a native client module with a mimetype. I need my packaged app to handle desktop files with a specific mimetype. As packaged app could be up and running without Chrome being displayed it seems possible, but the question is how ! Thanks for your advice and comments. Guy 回答1: You can handle files using this manifest section: http://developer

ElementById finds element but won't add event listener (Chrome extension)

你说的曾经没有我的故事 提交于 2019-12-24 21:05:55
问题 I have a form in my extension's popup with the code: <button type="submit" id="update" class="btn btn-primary">Submit</button> And then in the attached script, the following code: document.addEventListener("DOMContentLoaded", function(event){ var button = document.getElementById("update"); button.addEventListener("click", test); button.style.color="red"; }); function test(){ console.log("test"); } The "button.style.color="red"" portion of the code works, so I know that the button was found

Could you inject a script into a React page (with Draft.js editor) to append HTML to the existing contents of the editor?

一笑奈何 提交于 2019-12-24 20:01:31
问题 I'm looking to mash up Chrome Extension's ability to inject scripts with Draft.js's ability to add content to the editor. Would it be possible to inject a script like this into a React/Draft.js page, pass it a string (from the Chrome Extension), and have the script update the page? Many thanks for any thoughts/guidance... 来源: https://stackoverflow.com/questions/51845654/could-you-inject-a-script-into-a-react-page-with-draft-js-editor-to-append-htm

Intercepted XHR - run function before raising load

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 19:54:00
问题 On a web page with a extension-injected custom XMLHttpRequest class, I need to intercept and modify certain responses before the load event is raised on the rest of the document. Right now, my modification code reacts to the load event. How would I use a function to modify the response before the load event was fired? This is the code I am using: let oldXHROpen = window.XMLHttpRequest.prototype.open; window.XMLHttpRequest.prototype.open = function (method, url, async, user, password) { var

Get tab url from Chrome Extension in Javascript

霸气de小男生 提交于 2019-12-24 19:24:16
问题 I tried looking around Stackoverflow but couldn't find anything specifically for this. So basically, I have a share page for my website that goes like this: http://domain.com/share.php?link=http://sharing.url My extension goes like this: { ... "browser_action": { "default_icon": "icon.ico", "default_popup": "schare.html" } ... } schare.html: <style> body, html{ margin:0; padding:0; } iframe{ width:520px; height:200px; margin:0; } </style> <iframe id="iframes" frameborder="0"></iframe> <script

Mark.js keep marking permanently?

喜欢而已 提交于 2019-12-24 19:18:27
问题 i am currently using mark.js for a google chrome extension to highlight some text on a web page. Now whenever i refresh the page or do a right click all my marking is lost. Is there a way to keep that marking? As far as i see mark.js does not change the DOM. I would like to mark the text but also be able e.g. when i print that page or save it as a pdf, to maintain the highlighting i did.. That is the way i mark. it is pretty much the same as instructed on https://markjs.io/: function mark