Greasemonkey #exclude does nothing - greasemonkey

Greasemonkey script excludes do nothing, for some reason. They do not even seem to be recognized by Greasemonkey, and I would like to know why.
I have to go into the preferences for each script and add the excludes manually if I want the desired behavior. Apparently I'm getting the syntax correct, since a simple script like (there's nothing special about my choice of domain names, and I've checked it with others):
// ==UserScript==
// #name Delete Adsense Junk
// #exclude http://en.wikibooks.org/*
// #exclude https://en.wikibooks.org/*
// #include http://weather.org/*
// #include https://weather.org/*
// #version 1
// ==/UserScript==
alert("Alert!");
tells me all about where the script will and won't execute when I go to install it. Firefox wants to run the script on every page unless I navigate to the preferences for that script and change the user excludes though. The list of script excludes is empty and the include is just the wildcard. Is there some option that should be enabled/disabled that I'm missing? The user excludes seem to work normally. I'm just trying to figure out why Greasemonkey is ignoring the directives that I put in the script.

The script runs on the page and on all its frames. The alert box tells you which domain it is from (at least in FF). For example on YouTube it also runs for https://plus.google.com and https://s.ytimg.com. So for YouTube I get a total of 3 alerts and if youtube.com is excluded still 2 alerts.
Check out this post to see how to exclude them.

Related

#exclude in userscript not working as expected

I have a userscript that I would like to run for a particular domain, but not for a particular page.
For example, I want to stop the script from running when the URL contains documentMode=edit:
https://blah.itglue.com/2443511/docs/8093867#documentMode=edit&version=draft
I tried this:
// #exclude https://blah.itglue.com/*/docs/*#documentMode=edit
// #exclude https://blah.itglue.com/.*/docs/.*documentMode=edit&.*
// #match https://blah.itglue.com/*
However, the script still runs and I'm not sure what I'm doing wrong. I can see the URL added to exclude in Tampermonkey.
I checked this in a regex live editor and the above URL matches perfectly. I refreshed the page but the userscript is still applied....
However, if I use this, it stops the script loading on the page:
/(^[^:\/#\?]*:\/\/([^#\?\/]*\.)?blah\.itglue\.com(:[0-9]{1,5})?\/.*$)/
I don't want the script to stop working on the root domain though.....

How to change the style of a specific site with a Tampermonkey script?

Everytime I access a specific site like www.abc.com I want the background color to be red. How do I implement this condition in a tempermonkey script? Or is there a better way to do this?
In Tampermonkey the easiest way to change a style is to use the function GM.addStyle. Keep in mind you'll have to add the accordingly grant-tag in the header.
// ==UserScript==
// #name change the style of a specific site
// #match https://www.example.com/*
// #grant GM.addStyle
// ==/UserScript==
GM.addStyle("body{background-color:red!important}");

My Greasemonkey script runs on every site except the one I want it to?

I'm trying to set up a script to run on Quora, but it's running on every other site instead.
I have the #include directive in the metadata block, and under script settings/include, it's set to include *, and I can't see any way to remove that.
Here's a thread about the same issue I'm having, but there's no #exclude directive to remove (although I did try putting #exclude * before the #include, but that didn't fix anything). I also checked my formatting against the answer here and I don't see any typos.
Here's my metadata block.
// ==UserScript==
// #name Quora fixer
// #namespace quora
// #include https://www.quora.com/*
// #version 1
// #grant none
// #require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// #description prevents links from opening in a new tab
// #run-at document-idle
// ==UserScript==
First, see and follow My very simple Greasemonkey script is not running?.
If the script is running on every other page, and there are no Quora-specific #excludes, then the script most-likely is running on Quora -- just not doing what you expect.
Other issues or actions:
You are using #grant none and #require-ing jQuery. This leads to conflicts and javascript crashes on sites like Quora. Use #grant GM_addStyle.
If the Script Settings tab (not to be confused with the User Settings tab) shows differently than the actual script source, then either you are not looking at the same file Greasemonkey is, or Greasemonkey and/or Firefox has become corrupted/confused. In that case:
Uninstall the Greasemonkey script.
Completely clear the browser cache.
Shutdown Firefox completely. Use Task Manager, or equivalent, to verify that there is no Firefox thread/task/process in memory.
Go to your Firefox profile folder.
Enter the gm_scripts folder therein.
If there are any subfolders left over from the script you just uninstalled, delete them. In your case, the folders should have names similar to Quora_fixer.
Restart Firefox.
Make sure the script is not listed.
Install the Greasemonkey script afresh.
If it still doesn't work, create a new Firefox profile or try a different computer altogether.
Once the script fires on Quora and no relevant errors show on Firefox's Browser Console (see the first link above), then if the script still does not do what you expect, you may need to apply AJAX-aware techniques.

PySide/PyQt Text in QTextBrowser disappears after clicking on a link in it

I have the following variable appended to 'QTextBrowser'. It does appear as a link, but when I click on it all the text in the 'QTextBrowser' disappears. All the function the 'anchorClicked' signal is connected to does is print something in the shell so that I know that the signal was received.
word = '<a href>' + '<span style="background-color:#C0C0C0">' + word + '</span>' +'</a>'
self.textBrowser.anchorClicked.connect(self.test)
def test(self,argv_1):
print('!!!')
Probably what's happening is that the text browser is attempting navigate to the href specified in the anchor. But since the href is empty, it just shows a blank page.
If you want to stop automatic link navigation, try this:
self.textBrowser.setOpenLinks(False)
(NB: the anchorClicked signal will still be sent when the link is clicked).
You can also prevent this behaviour by calling self.textBrowser.setSource(QtCore.QUrl()) in the function connected to the anchorClicked signal (in your case test()).
For an example, see what I did in my answer to your other question here: https://stackoverflow.com/a/19475367/1994235
This allows you to still have some links that take you to other pages, and some that don't (you call the above line of code to prevent the page change, only when certain urls are passed to your function)
Use html2text to download the URL to matching directory for every link on the page. Reformat as HTML, adding headers and rewiring the links. Then do this recursively every time you click on a link and you effectively have a working web browser. The links will actually work. I would like to see someone do it in less than 3 pages if they can.

How to display modules only on search results in Joomla 2.5?

Hello please read the whole question, this isn't just solved by enabling the modules only for the search page:
I have a few modules that are exclusively shown on the search page in Joomla.
I created a hidden menu entry for the search as well in order to tell modules to only show on this page. This works alright, but when I click one of the results and get redirected to the actual result, then the modules, which should only show up on the search page are still shown in the result page.
Any clue how to fix this? Really annoying as I use 3rd party search enhancing modules, and they are showing on the results.
Using standard Joomla, there's no way to target modules to only the search results page and none of the pages that link off the results – but I know you knew that! The hidden menu item is a help, but does not change the menu item of some of the links off that page. It's all to do with the allocation and use of "Itemids" in Joomla.
To be able to target modules more specifically, you need to use a 3rd-party extension. I developed MetaMod (www.metamodpro.com) to cope with exactly this use case. MetaMod is a wrapper module that can then decide just which other module to include in itself (or not). So you assign the MetaMod to the page, then put a snippet of code inside the MetaMod which decides which other module to include.
In this case, I'd use the following in MetaMod:
if ($core_genius->check("pagetype = search, searchresults")) return XXX;
// replace XXX with the module id of the module to include
// ONLY on the search page, or the searchresults page, but
// no other type of page.
Hope that helps,
Stephen
Although MetaMod is great (I've used it myself & Stephen's support is great!) there is another way to do it without using 3rd party extensions.
You could create new module positions in your template above (or below) the module positions you wanted to use and wrap them in an if statement like so:
<?php if(!isset(JRequest::getString('searchword'))) : ?>
<jdoc:include type="modules" name="right-search" style="xhtml" />
<?php endif; ?>

Resources