userscripts

window.onload works in Firefox+Greasemonkey script but not in a Chrome userscript?

时光怂恿深爱的人放手 提交于 2019-12-19 06:16:09
问题 There is a page http://example.com/1.php that includes javascript file as usual: <script type="text/javascript" src="/util.js?1354729400"></script> This file contain function named exampleFunction which I need to use in my userscript. Also I have an user script: // ==UserScript== // @name SomeName // @namespace http://example.com/userscripts // @description Greets the world // @include http://example.com/* // ==/UserScript== window.onload = function () { console.log(exampleFunction); alert(

How do I add a userscript installation button to my web page?

本小妞迷上赌 提交于 2019-12-19 04:31:09
问题 I need to host a userscript on an internal company website. How do I build the href so that Greasemonkey will install the userscript when the link is clicked? I tried a simple <a href="user.js">Install Userscript</a> but Chrome and Firefox simply show the file source instead of installing the userscript. 回答1: Your link should look like: <a href="https://example.com/your_script.user.js">Click to install script X</a> <small>(A userscript engine, like Tampermonkey, is required.)</small> In order

Accessing iframes from a Chrome content-script extension

被刻印的时光 ゝ 提交于 2019-12-18 11:08:55
问题 I'm writing a Chrome extension that needs to alter a popular web app when loaded. Unfortunately, most of the UI of that web app is rendered inside an iframe, and although the address of that iframe matches my content_scripts match declaration, the user script only gets invoked for the top frame. Q: Is there a method of accessing HTML rendered inside an iframe from a Chrome content script extension? If yes, what permissions and other manifest options should I specify? Thanks. 回答1: I've

Log a web page's dynamically-created, DOM elements with a userscript

孤街浪徒 提交于 2019-12-18 09:18:13
问题 I want to extract all the dynamic javascript functions from a web page, with a userscript. Someone suggested using a hook for DOM objects. They also provided this example: var f = document.createElement;document.createElement = function(tagName){ console.log(tagName); f.apply(document, arguments); } I think this functions logs all the document.createElement() calls, but where do I add this function in my userscript? I tried creating a userscript which contains only this function, but it did

Tampermonkey to select a dropdown value. It has no ID or name, just a class?

ぃ、小莉子 提交于 2019-12-18 08:57:07
问题 I'm writing a Tampermonkey code for a webpage like ConverTo: It's supposed to automatically select the second option in a dropdown: <select class="format-select"> <option value="mp3">MP3</option> <option value="mp4">MP4 (video)</option> </select> , several seconds after the page is fully loaded. But nothing happens. My code: ...... // @match https://www.converto.io/* // @require http://code.jquery.com/jquery-1.11.0.min.js // ==/UserScript== $(document).ready(function(){ setTimout(test(),10000

My userscript only works when the page is refreshed or on iframes, not the main page?

∥☆過路亽.° 提交于 2019-12-18 06:23:33
问题 This simple code doesn't work on a Facebook page. This code only alerts when I refresh the page. If I go to that page from my Facebook profile, with my mouse; The script stops working. There are no alerts or errors. :( It looks like the whole script doesn't work until I refresh. // ==UserScript== // @name Purge My Facebook // @namespace http://www.arda.com // @description test // @include https://*.facebook.com* // @include http://*.facebook.com* // @version 1 // ==/UserScript== window

Can a userscript delete cookies from a given domain?

五迷三道 提交于 2019-12-18 05:57:45
问题 Can Greasemonkey delete cookies from a given domain? If so, how? 回答1: There are major limitations on what Greasemonkey can delete. Other tools may be better for what you want, see below. But, if all of these conditions are met: The cookies you want to delete are on the current page's domain. They are not "Secure cookies". You loop through the possible paths, including / , a blank path, etc. No cookies are set by javascript, after the page loads. The thing tracking you really is a "cookie".

How to redirect to one out of given set of sites?

£可爱£侵袭症+ 提交于 2019-12-17 20:59:59
问题 I created a userscript to redirect to one out of the specified multiple sites: // ==UserScript== // @id fvhfy464 // @name [udit]redirector to yahoo or google // @version 1.0 // @namespace // @author // @description // @include http://yahoo.com // @include http://google.com // @include http://bing.com // @run-at document-end // ==/UserScript== setTimeout(function() { window.location.href("http://yahoo.com","http://google.com","http://bing.com") }, 4000); But it doesn't work. (From comments:) I

Downloading an image using XMLHttpRequest in a userscript

邮差的信 提交于 2019-12-17 15:44:39
问题 First of all there is a question with the same title here on SO but its not what I'm looking for and it doesn't have a complete answer either. So here's my question. Say I have this URL which directs to an image. https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/299595_10150290138650735_543370734_8021370_355110168_n.jpg Once I put this parameter ?dl=1 to the end of the URL, it becomes downloadable. https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/299595_10150290138650735_543370734

Chrome userscript error: “Unsafe JavaScript attempt to access frame”

你。 提交于 2019-12-17 13:23:48
问题 // the iframe of the div I need to access var iframe = document.getElementsByTagName("iframe")[2]; var innerDoc = iframe.contentDocument || iframe.contentWindow.document; // resize 'player' in the iframe innerDoc.getElementById('player').width = "1000px"; innerDoc.getElementById('player').height = "650px"; Running in a userscript for this url: http://www.free-tv-video-online.me/player/sockshare.php?id=24DA6EAA2561FD60 Why does Chrome come out with this error and fail the script?: Unsafe