I'm wiring a Chrome extension which needs to be able to detect whenever a thread on 4chan has been updated (threads autoupdate). I've tried using a MutationObserver, but it is being set off too many times (4chan thread pages change often for a variety of reasons outside of new posts, including hovering over/expanding images, viewing post replies, opening the reply dialog, etc.)
I'm at work, so I can't visit 4chan to help you more specifically :^)
But, you should find out the distinguishing class or attribute of each post, e.g. by using Chrome's Inspect, store the last post ID (i.e. the dubs, trips, quads-meter), and on each mutation event, check if the last post ID matches the previous post ID, to determine whether there has been new posts.
There is probably a more efficient way to detect only posts, but this should do the job just fine, if you're already familiar with MutationObserver.
Related
I've been trying to figure out a way to record user interface actions to retrieve information about which ribbon buttons were clicked, but I've been unsuccessful so far.
I've spend a lot of time finding the related events in the API, but apparently there are none.
There are many ways to record user events in Revit. One of the simplest ways is to look at the journal file. It is always generated and stored automatically by Revit, so you don't have to do anything at all to obtain it. Look at its contents; all relevant user interactions are recorded there.
As said, there are other ways as well.
Afaik, recording which buttons are clicked is not officially supported and may be a bit tricky, cf. the Revit API discussion forum thread on obtaining button name using events for plugins working inside of another plugin.
I'm working on a Chrome extension that'll need to display some messages to the users, be them instructions or errors. Right now the former are completely missing and errors are displayed in alert boxes.
We came up with this
alert(message); Not great, especially for instructions. Currently used.
chrome.notifications are not meant to be used this way: they appear off-center and disappear before the user may be done reading.
appending html content to the current tab, which we see as a last resort since we don't want to risk conflicts
Is there a better way to inform the user?
There is some other ways to do that, although none of them can be what you are looking for. Anyway, I'll share my solutions
1) Customizing default popup
You can append customized content to your popup window and let your users informed by setting the badge text:
chrome.browserAction.setBadgeText({text: "error"})
See https://developer.chrome.com/extensions/browserAction#method-setBadgeText
I think this is the best solution to show errors because your user won't be annoyed
2) Creating a new tab
To show instructions most extensions I used creates a new tab
chrome.tabs.create({url: "instructions.html"});
See https://developer.chrome.com/extensions/tabs#method-create
This occurs usually after the user installs the extension.
We ended up using humane.js to show messages on the page since it only required two small files, both of which have been "isolated" to avoid any possible CSS class clash with the existing content.
Still not ideal since I'd rather not having to add any elements/CSS to the page, but that's the best we got now.
I'm trying to identify if a tab for which I received "webNavigation.onCompleted" is an "actual" tab.
As described in the documentation:
http://developer.chrome.com/extensions/webNavigation.html
A short quote from the docs:
A note about tab IDs :
Not all navigating tabs correspond to actual tabs in Chrome's UI, e.g., a tab that is being pre-rendered. Such tabs are not accessible via the tabs API nor can you request information about them via webNavigation.getFrame or webNavigation.getAllFrames. Once such a tab is swapped in, an onTabReplaced event is fired and they become accessible via these APIs.
So now when I get an event I encounter 2 problems when trying to figure out if the tab is "actual":
The scenario as described in the documentation, however I see that onTabReplaced can called before/after onCompleted,
or even not called even though I expect it to be called since I dont have the tab id in a list of tabs I create in tabs.onCreate,
and later the page is displayed in a tab.
Pages that are pre-rendered in Google chrome pages (e.g google for "ford"), and eventually dont become to show on tabs.
In case you're not familiar with pre-rendering:
https://support.google.com/chrome/answer/1385029?hl=en
I consider these cases to be different because I see in difference in pre-rendered pages,
that end u to be tads, and the ones who are not used eventually.
One page is eventually "navigated to", while the other on is just "cached".
But this difference can not be detected by using the webNavigation api, as far I as could find.
So my question - is there any way to distinguish (hopefully using the webNaviagtion api),
between an "actual" tab, a pre-rendered page which is going to be displayed as tab,
and a pre-rendered page that is going stay in cache (for now) ?
Just 2 clarifications, about solutions that supposedly I can use, but they look to me "not good",
at least at this stage.
The docs say "Such tabs are not accessible via the tabs API".
so technically I can try an use this API, get an exception, and this way figure out it's "pre-renderd" tab,
but I dont like my code to use exceptions for this, so I'm looking for a "clean" way.
in webNavigation.onComplete, I can set a timeout for 1 second,
and then if in this one second, onTabReplaced, I can figure out that this tab was
moved to be an "actual" tab. and not stayed in "cache".
But during this 1 second, or any duration I choose, there can be a lot of other events,
and even the tab can be closed.
So again, I'm looking for a "clean" solution.
Thanks for your help.
I've got a standard blog-type application with posts and users that can add those posts to their favorites.
Goals
When a user looks at a list of posts, they should see an indication (an image) of whether
each post is a favorite. Anonymous users don't have any favorites.
The list of posts needs to be cached in Varnish (for both anonymous and logged-in users) because it's expensive to calculate.
Ideas
Cache the list page in Varnish and use ESI to fetch the favorites information...
... for each post for the user making the current request. Downside: 50 ESI requests per page (basically the N+1 problem).
... as a JSON object which is then stored on the page. On the client, this object is read and the DOM is manipulated to indicate favorites information. Downside: doesn't work for users without Javascript.
... as a CSS snippet which is stored in the page. The CSS determines what to display for each post. Downside: only works for stylable content (ie, images). Not possible to display text information.
Am I missing any possibilities to accomplish what I want? Idea 3 seems to be the cleverest answer, but it wouldn't work if I also wanted to display the date the user favorited the post.
Answer 2 makes a lot of sense. It makes pages nicely cacheable, and only sacrifices the 'favorite functionality' for people without javascript in their browser.
Who are those people anyway? Still surfing with lynx? ;). And would they accept cookies to make your login mechanism (required for personal favorites) work in the first place, or even login at all?
Whenever I save or create a node of a certain user-defined type, I am back in the edit window instead of switching to the first tab labeled view. All my fields (body, title etc. are as they were and no message appears, neither directly on the page nor in the watchdog database log. The validation is working, though, because I see those 'required' messages as soon as I try to save without Title for example.
The strange thing is that when I create a new content type, or use the predefined story and page types, I can edit and create nodes. In the latter case, Drupal answers with an 302 redirect, whereas with the proplematic content types, only a 200 HTTP status is returned.
The issue doesn't seem to be related to either JavaScript (on or off, no difference), Browser (tried Chrome and Firefox) or WYSIWYG (used input formats with and without).
I'm using Drupal 6.22 and the CCK. I have about 7 content types, some of them with fields. I am not using Rules, but a multitude of modules, all of which are up-to-date. I will post a list if this issue can't be solved otherwise.
I have spend the last hours trying to figure this out, both by looking at my installation (settings, database) and by searching Google & Co.
Any ideas?
The situation appeared because Drupal translated both the Upload and the Save button to one word, Speichern. The FileField issue tracker contains the corresponding thread: http://drupal.org/node/684426
The ImageField and Locale modules, along with a language such as German or Finnish were partly responsible for the trouble.