userscripts

Writing a userscript that replaces a background image

社会主义新天地 提交于 2019-12-02 19:51:17
问题 This is the code // ==UserScript== // @name Wood Background // @namespace http://www.nationstates.net/nation=ellorn // @description Changes background to wood finish // @include http:*//w11.zetaboards.com/Allied_Republics/* // ==/UserScript== function addCss(cssString) { var head = document.getElementsByTagName('head')[0]; return unless head; var newCss = document.createElement('style'); newCss.type = "text/css"; newCss.innerHTML = cssString; head.appendChild(newCss); } addCss ( '* {

Twitter userscript affects pages other than the intended (@included) ones?

烈酒焚心 提交于 2019-12-02 13:37:10
问题 The below UserScript is meant to work on my own twitter profile page (not the timeline). // ==UserScript== // @name CoolScript // @include https://twitter.com/IJNanayakkara // @include https://twitter.com/IJNanayakkara/status/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @version 1.0 // @license GPL v3 or any later version (http://www.gnu.org/copyleft/gpl.html) // @grant GM_addStyle // ==

Userscript code works in Firefox but not in Chrome? (unsafeWindow)

。_饼干妹妹 提交于 2019-12-02 12:06:00
I am using this userscript in Firefox that counts unread tweets in Tweetdeck and colors the new tweets. It works fine with Firefox (Greasemonkey), but in Chrome I'm not getting anything. Here is the code: // ==UserScript== // @name TweetDeck Unread Notifications // @include https://tweetdeck.twitter.com // @include https://tweetdeck.twitter.com/* // @grant none // ==/UserScript== var head, style; head = document.getElementsByTagName('head')[0]; style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = ".tdUnreadUnread { background-color: #444444; }"; head.appendChild

Modify new elements when they are added

拈花ヽ惹草 提交于 2019-12-02 11:58:14
This is done by my userscript on page load: $('a.people').each(function (index, value) { $('<i>'+$(value).text()+'</i>').insertBefore(value); }); The web app the userscript targets, adds new $('a.people') elements when the user does various actions. How can I run my code for the newly added elements? Is there an event which is triggered when new elements are added to the DOM? I don't want to use setInterval because the code will loop when not required and affect the performance. If you want to act on new elements when the target page adds them, you have two choices: MutationObserver or Polling

Pass a variable to new page

江枫思渺然 提交于 2019-12-02 11:51:42
I am trying to pass a variable from one page, load another and enter that information. something Like this: When 127.0.0.1/test.html&ID=1234 location.href = "127.0.0.1/newpage.html" if (location.href == newpage.html){ var e = document.GetElementById("Loginbx"); e.Value = ID } I don't have access to modify 127.0.0.1/test.html nor newpage.html but would like to pass variables to them from another. Is this possible? You could pass the values on the query string and then read those: location.href = "http://127.0.0.1/newpage.html?foo=1&bar=2"; Then use location.search to get the query string and

Ajax: How to know if a user script implementation doesn't set the Origin header?

独自空忆成欢 提交于 2019-12-02 09:58:19
Some user script implementations (like Google Chrome) allow direct cross AJAX requests, but some others don't, and use Same Origin Policy restrictions. Here's a part of code: /* * Get the size of the file. * @Button the current button for downloading the video. * @Url the http url of the video. */ function SetFileSize(Button, Url) { var ajax = new XMLHttpRequest(); ajax.onloadend = function () { GetResolution(Button, Url, ' - ' + (parseInt(this.getResponseHeader("Content-Length")) / 1048576).toFixed(3) + ' Mo') } ajax.open('HEAD', Url, true); // <-- HEAD allow to get only the data of the

Javascript variable scope in a JS URI, or how to write page-scope objects?

流过昼夜 提交于 2019-12-02 08:12:08
问题 I'm writing a Greasemonkey script that I'm trying to use in Chrome and Firefox. I know you can't use unsafewindow in Chrome like you can in Firefox, so I've been attempting to use jS-uris like in the answer for: Greasemonkey, Chrome and unsafeWindow.foo(). when I try the following: location.assign("javascript:var tutu = 'oscar';"); location.assign("alert('1:' + tutu);"); alert('2:' + tutu); I receive an error showing that "tutu" is undefined. Obviously what I'm not understanding is the scope

Writing a userscript that replaces a background image

笑着哭i 提交于 2019-12-02 07:33:42
This is the code // ==UserScript== // @name Wood Background // @namespace http://www.nationstates.net/nation=ellorn // @description Changes background to wood finish // @include http:*//w11.zetaboards.com/Allied_Republics/* // ==/UserScript== function addCss(cssString) { var head = document.getElementsByTagName('head')[0]; return unless head; var newCss = document.createElement('style'); newCss.type = "text/css"; newCss.innerHTML = cssString; head.appendChild(newCss); } addCss ( '* { background: #00ff00 url('http://awesomewallpapers.files.wordpress.com/2010/01 /wooden_top.jpg') no-repeat fixed

How to loop through GET/POST calls sequentially (waiting for previous) return?

五迷三道 提交于 2019-12-02 05:36:55
I'm writing a Tampermonkey script for a web page and trying to extract data from other pages. I'm trying to make a function that has a loop inside that goes thru a list, llcList , and retrieves data from ajax method GET, but would like to wait for to finish one request before going to second one. Bonus would be if I could make it wait some extra time. What should happen: send request for a llcList[0] get return data, process it wait some time send new request for a llcList[1] Is this possible? I tried few methods, every time loop send all requests not a second apart. : function F_Company_LLC()

Javascript variable scope in a JS URI, or how to write page-scope objects?

大城市里の小女人 提交于 2019-12-02 04:39:29
I'm writing a Greasemonkey script that I'm trying to use in Chrome and Firefox. I know you can't use unsafewindow in Chrome like you can in Firefox, so I've been attempting to use jS-uris like in the answer for: Greasemonkey, Chrome and unsafeWindow.foo() . when I try the following: location.assign("javascript:var tutu = 'oscar';"); location.assign("alert('1:' + tutu);"); alert('2:' + tutu); I receive an error showing that "tutu" is undefined. Obviously what I'm not understanding is the scope of these variables. I need to make global functions and variables for what I'm working on. What am I